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_KOTOR2_OBJECT_H
26 #define ENGINES_KOTOR2_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 KotOR2 {
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 
74  // Interactive properties
75 
76  bool isStatic() const;
77  bool isUsable() const;
78 
79  bool isClickable() const;
80 
81  // Positioning
82 
84  virtual void getPosition(float &x, float &y, float &z) const;
86  virtual void getOrientation(float &x, float &y, float &z, float &angle) const;
87 
89  virtual void setPosition(float x, float y, float z);
91  virtual void setOrientation(float x, float y, float z, float angle);
92 
93  void makeLookAt(float x, float y);
94  void makeLookAt(Object *target);
95 
97  Room *getRoom();
99  void setRoom(Room *room);
100 
101  // Object/Cursor interactions
102 
103  virtual void enter();
104  virtual void leave();
105 
107  virtual void highlight(bool enabled);
108 
110  virtual bool click(Object *triggerer = 0);
111 
112  // Sound
113 
115  void stopSound();
117  void playSound(const Common::UString &sound, bool pitchVariance = false);
118 
119  // Animation
120 
121  virtual void playAnimation(const Common::UString &anim,
122  bool restart = true,
123  float length = 0.0f,
124  float speed = 1.0f);
125 
126 protected:
128 
131 
133 
134  bool _static;
135  bool _usable;
136 
137  std::list<uint32> _ids;
138 
139  float _position[3];
140  float _orientation[4];
141 
143 
145 };
146 
147 } // End of namespace KotOR2
148 
149 } // End of namespace Engines
150 
151 #endif // ENGINES_KOTOR2_OBJECT_H
bool isStatic() const
Is the object static (not manipulable at all)?
Definition: object.cpp:91
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:107
Room * getRoom()
Get a room the object is in.
Definition: object.cpp:144
A class holding an UTF-8 string.
Definition: ustring.h:48
void stopSound()
Stop the current object sound.
Definition: object.cpp:165
virtual void playAnimation(const Common::UString &anim, bool restart=true, float length=0.0f, float speed=1.0f)
Definition: object.cpp:177
float _position[3]
The object&#39;s position.
Definition: object.h:139
float _orientation[4]
The object&#39;s orientation.
Definition: object.h:140
virtual void hideSoft()
Hide the object&#39;s model(s) if applicable.
Definition: object.cpp:71
virtual bool click(Object *triggerer=0)
The object was clicked.
Definition: object.cpp:161
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:121
Basic sound types.
virtual bool isVisible() const
Is the object&#39;s model(s) visible?
Definition: object.cpp:75
bool _usable
Is the object usable?
Definition: object.h:135
An object containing scripts.
virtual void enter()
The cursor entered the object.
Definition: object.cpp:152
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object&#39;s orientation.
Definition: object.cpp:113
virtual void hide()
Hide the object&#39;s model(s).
Definition: object.cpp:68
virtual void highlight(bool enabled)
(Un)Highlight the object.
Definition: object.cpp:158
bool isClickable() const
Can the player click the object?
Definition: object.cpp:99
const Common::UString & getDescription() const
Return the object&#39;s description.
Definition: object.cpp:83
std::list< uint32 > _ids
The object&#39;s model IDs.
Definition: object.h:137
Common::UString _name
The object&#39;s display name.
Definition: object.h:129
Basic Star Wars: Knights of the Old Republic II - The Sith Lords type definitions.
Common::UString _portrait
The object&#39;s portrait.
Definition: object.h:132
Low-level type definitions to handle fixed width types portably.
void setRoom(Room *room)
Set a room the object is in.
Definition: object.cpp:148
Sound::ChannelHandle _sound
The currently playing object sound.
Definition: object.h:142
ObjectType _type
The object&#39;s type.
Definition: object.h:127
bool isUsable() const
Can the object be used by the PC?
Definition: object.cpp:95
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:169
Unicode string handling.
An NWScript object.
ObjectType getType() const
Return the exact type of the object.
Definition: object.cpp:61
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:33
A handle to a sound channel.
Definition: types.h:35
virtual void setOrientation(float x, float y, float z, float angle)
Set the object&#39;s orientation.
Definition: object.cpp:127
bool _static
Is the object static?
Definition: object.h:134
virtual void show()
Show the object&#39;s model(s).
Definition: object.cpp:65
const Common::UString & getPortrait() const
Return the object&#39;s portrait.
Definition: object.cpp:87
virtual void leave()
The cursor left the object.
Definition: object.cpp:155
void makeLookAt(float x, float y)
Definition: object.cpp:134
Room * _room
Room the object is in.
Definition: object.h:144
const std::list< uint32 > & getIDs() const
Return the object&#39;s model IDs.
Definition: object.cpp:103
const Common::UString & getName() const
Return the object&#39;s name.
Definition: object.cpp:79
Common::UString _description
The object&#39;s description.
Definition: object.h:130