xoreos  0.0.5
object.h
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #ifndef ENGINES_KOTOR_OBJECT_H
26 #define ENGINES_KOTOR_OBJECT_H
27 
28 #include <list>
29 
30 #include "src/common/types.h"
31 #include "src/common/ustring.h"
32 
34 
35 #include "src/sound/types.h"
36 
38 
40 
41 namespace Engines {
42 
43 namespace KotOR {
44 
45 class Room;
46 
48 public:
50  virtual ~Object();
51 
53  ObjectType getType() const;
54 
55  // Basic visuals
56 
57  virtual void show();
58  virtual void hide();
59  virtual void hideSoft();
60  virtual bool isVisible() const;
61 
63  const std::list<uint32> &getIDs() const;
64 
65  // Basic properties
66 
68  const Common::UString &getName() const;
70  const Common::UString &getDescription() const;
72  const Common::UString &getPortrait() const;
73 
75  void setMaxHitPoints(int maxHP);
77  int getMaxHitPoints();
79  void setCurrentHitPoints(int hitpoints);
81  int getCurrentHitPoints();
83  void setMinOneHitPoints(bool enabled);
85  bool getMinOneHitPoints() const;
86 
87  // Interactive properties
88 
89  bool isStatic() const;
90  bool isUsable() const;
91 
92  bool isClickable() const;
93 
94  // Positioning
95 
97  virtual void getPosition(float &x, float &y, float &z) const;
99  virtual void getOrientation(float &x, float &y, float &z, float &angle) const;
100 
102  virtual void setPosition(float x, float y, float z);
104  virtual void setOrientation(float x, float y, float z, float angle);
105 
106  void makeLookAt(float x, float y);
107  void makeLookAt(Object *target);
108 
110  Room *getRoom();
112  void setRoom(Room *room);
113 
114  // Object/Cursor interactions
115 
116  virtual void enter();
117  virtual void leave();
118 
120  virtual void highlight(bool enabled);
121 
123  virtual bool click(Object *triggerer = 0);
124 
125  // Sound
126 
128  void stopSound();
130  void playSound(const Common::UString &sound, bool pitchVariance = false);
131 
132  // Animation
133 
134  virtual void playAnimation(const Common::UString &anim,
135  bool restart = true,
136  float length = 0.0f,
137  float speed = 1.0f);
138 
139 protected:
141 
144 
146 
147  bool _static;
148  bool _usable;
149 
153 
154  std::list<uint32> _ids;
155 
156  float _position[3];
157  float _orientation[4];
158 
160 
162 };
163 
164 } // End of namespace KotOR
165 
166 } // End of namespace Engines
167 
168 #endif // ENGINES_KOTOR_OBJECT_H
virtual void hide()
Hide the object&#39;s model(s).
Definition: object.cpp:72
void stopSound()
Stop the current object sound.
Definition: object.cpp:196
Room * _room
Room the object is in.
Definition: object.h:161
bool _static
Is the object static?
Definition: object.h:147
Sound::ChannelHandle _sound
The currently playing object sound.
Definition: object.h:159
A class holding an UTF-8 string.
Definition: ustring.h:48
const Common::UString & getPortrait() const
Return the object&#39;s portrait.
Definition: object.cpp:91
virtual void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: object.cpp:208
Basic sound types.
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:33
Common::UString _description
The object&#39;s description.
Definition: object.h:143
bool isStatic() const
Is the object static (not manipulable at all)?
Definition: object.cpp:122
ObjectType getType() const
Return the exact type of the object.
Definition: object.cpp:65
virtual void hideSoft()
Hide the object&#39;s model(s) if applicable.
Definition: object.cpp:75
virtual void show()
Show the object&#39;s model(s).
Definition: object.cpp:69
void setCurrentHitPoints(int hitpoints)
Set the current hitpoints.
Definition: object.cpp:103
int getCurrentHitPoints()
Return the objects current hitpoints.
Definition: object.cpp:110
Common::UString _portrait
The object&#39;s portrait.
Definition: object.h:145
const Common::UString & getName() const
Return the object&#39;s name.
Definition: object.cpp:83
bool isClickable() const
Can the player click the object?
Definition: object.cpp:130
Common::UString _name
The object&#39;s display name.
Definition: object.h:142
float _position[3]
The object&#39;s position.
Definition: object.h:156
Room * getRoom()
Get a room the object is in.
Definition: object.cpp:175
virtual bool isVisible() const
Is the object&#39;s model(s) visible?
Definition: object.cpp:79
ObjectType _type
The object&#39;s type.
Definition: object.h:140
virtual void setOrientation(float x, float y, float z, float angle)
Set the object&#39;s orientation.
Definition: object.cpp:158
bool getMinOneHitPoints() const
Get if the object has a minimum of one hp.
Definition: object.cpp:118
float _orientation[4]
The object&#39;s orientation.
Definition: object.h:157
int getMaxHitPoints()
Get the maximum hit points for the objects.
Definition: object.cpp:99
void setMinOneHitPoints(bool enabled)
Set if the object has a minimum of one hp.
Definition: object.cpp:114
Low-level type definitions to handle fixed width types portably.
const std::list< uint32 > & getIDs() const
Return the object&#39;s model IDs.
Definition: object.cpp:134
int _currentHitPoints
The current hitpoints of the object.
Definition: object.h:150
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object&#39;s orientation.
Definition: object.cpp:144
bool isUsable() const
Can the object be used by the PC?
Definition: object.cpp:126
bool _minOneHitPoint
If the object should have at least one hitpoint.
Definition: object.h:152
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:200
Unicode string handling.
virtual void enter()
The cursor entered the object.
Definition: object.cpp:183
std::list< uint32 > _ids
The object&#39;s model IDs.
Definition: object.h:154
An NWScript object.
virtual bool click(Object *triggerer=0)
The object was clicked.
Definition: object.cpp:192
int _maxHitPoints
The maximum hitpoints of the object.
Definition: object.h:151
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:152
void makeLookAt(float x, float y)
Definition: object.cpp:165
A handle to a sound channel.
Definition: types.h:35
virtual void leave()
The cursor left the object.
Definition: object.cpp:186
An object containing scripts.
void setRoom(Room *room)
Set a room the object is in.
Definition: object.cpp:179
void setMaxHitPoints(int maxHP)
Set the maximum hit points for the objects.
Definition: object.cpp:95
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:138
bool _usable
Is the object usable?
Definition: object.h:148
virtual void highlight(bool enabled)
(Un)Highlight the object.
Definition: object.cpp:189
const Common::UString & getDescription() const
Return the object&#39;s description.
Definition: object.cpp:87
Basic Star Wars: Knights of the Old Republic type definitions.