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_NWN2_OBJECT_H
26 #define ENGINES_NWN2_OBJECT_H
27 
28 #include <list>
29 
30 #include "src/common/types.h"
31 #include "src/common/scopedptr.h"
32 #include "src/common/ustring.h"
33 
35 
36 #include "src/sound/types.h"
37 
38 #include "src/engines/nwn2/types.h"
40 
42 
43 namespace Aurora {
44  class SSFFile;
45 
46  namespace NWScript {
47  class Object;
48  }
49 }
50 
51 namespace Engines {
52 
53 namespace NWN2 {
54 
55 class Area;
56 
59 public:
61  virtual ~Object();
62 
64  ObjectType getType() const;
65 
66  // Basic visuals
67 
68  virtual void loadModel();
69  virtual void unloadModel();
70 
71  virtual void show();
72  virtual void hide();
73 
75  const std::list<uint32> &getIDs() const;
76 
77  // Basic properties
78 
80  const Common::UString &getName() const;
82  const Common::UString &getDescription() const;
83 
85  const Common::UString &getConversation() const;
86 
88  const Aurora::SSFFile *getSSF();
89 
90  // Interactive properties
91 
92  bool isStatic() const;
93  bool isUsable() const;
94 
95  bool isClickable() const;
96 
97  // Object/Object interactions
98 
100  Area *getArea() const;
102  void setArea(Area *);
103 
104  // Positioning
105 
107  virtual void getPosition(float &x, float &y, float &z) const;
109  virtual void getOrientation(float &x, float &y, float &z, float &angle) const;
110 
112  virtual void setPosition(float x, float y, float z);
114  virtual void setOrientation(float x, float y, float z, float angle);
115 
117  Location getLocation() const;
118 
119  // Object/Cursor interactions
120 
121  virtual void enter();
122  virtual void leave();
123 
125  virtual void highlight(bool enabled);
126 
128  virtual bool click(Object *triggerer = 0);
129 
130  // Object (text) talking
131 
133  void speakString(const Common::UString &string, uint32 volume);
135  void speakOneLiner(Common::UString conv, Object *tokenTarget = 0);
136 
137  // Sound
138 
140  void stopSound();
142  void playSound(const Common::UString &sound, bool pitchVariance = false);
143 
144 protected:
146 
149 
151 
154 
155  bool _static;
156  bool _usable;
157 
158  std::list<uint32> _ids;
159 
161 
162  float _position[3];
163  float _orientation[4];
164 
166 
167 
169  void loadSSF();
170 
172  void readVarTable(const Aurora::GFF3List &varTable);
173  void readVarTable(const Aurora::GFF3Struct &gff);
174 };
175 
176 } // End of namespace NWN2
177 
178 } // End of namespace Engines
179 
180 #endif // ENGINES_NWN2_OBJECT_H
Sound::ChannelHandle _sound
The currently playing object sound.
Definition: object.h:165
void stopSound()
Stop the current object sound.
Definition: object.cpp:280
bool isClickable() const
Can the player click the object?
Definition: object.cpp:114
float _orientation[4]
The object&#39;s orientation.
Definition: object.h:163
A class holding an UTF-8 string.
Definition: ustring.h:48
Area * getArea() const
Return the area this object is currently in.
Definition: object.cpp:122
An area in Neverwinter Nights 2, holding all objects, room tiles and terrain within, as well as general area properties like the current background music and ambient sounds.
Definition: area.h:65
Class to hold a sound set.
Definition: ssffile.h:55
virtual void loadModel()
Load the object&#39;s model(s).
Definition: object.cpp:76
const Common::UString & getDescription() const
Return the object&#39;s description.
Definition: object.cpp:92
virtual void getOrientation(float &x, float &y, float &z, float &angle) const
Return the object&#39;s orientation.
Definition: object.cpp:148
void speakOneLiner(Common::UString conv, Object *tokenTarget=0)
Speak an one-liner from the specified conversation file.
Definition: object.cpp:251
A location within a Neverwinter Nights 2 area.
uint32 _soundSet
The object&#39;s sound set, as an index into soundset.2da.
Definition: object.h:152
Basic sound types.
virtual void highlight(bool enabled)
(Un)Highlight the object.
Definition: object.cpp:175
Common::UString _name
The object&#39;s display name.
Definition: object.h:147
An object within a NWN2 area.
Definition: object.h:58
void readVarTable(const Aurora::GFF3List &varTable)
Read the object&#39;s variable table.
Definition: object.cpp:200
A simple scoped smart pointer template.
ObjectType _type
The object&#39;s type.
Definition: object.h:145
virtual void leave()
The cursor left the object.
Definition: object.cpp:172
virtual void hide()
Hide the object&#39;s model(s).
Definition: object.cpp:85
bool _usable
Is the object usable?
Definition: object.h:156
virtual ~Object()
Definition: object.cpp:68
std::list< uint32 > _ids
The object&#39;s model IDs.
Definition: object.h:158
float _position[3]
The object&#39;s position.
Definition: object.h:162
Basic Neverwinter Nights 2 type definitions.
void speakString(const Common::UString &string, uint32 volume)
Speak the specified string.
Definition: object.cpp:245
const Common::UString & getConversation() const
Return the object&#39;s default conversation (DLG).
Definition: object.cpp:96
Common::UString _conversation
The object&#39;s default conversation.
Definition: object.h:150
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:118
const Aurora::SSFFile * getSSF()
Return the object&#39;s sound set.
Definition: object.cpp:100
virtual void enter()
The cursor entered the object.
Definition: object.cpp:169
const Common::UString & getName() const
Return the object&#39;s name.
Definition: object.cpp:88
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
Unicode string handling.
virtual void setOrientation(float x, float y, float z, float angle)
Set the object&#39;s orientation.
Definition: object.cpp:162
bool isStatic() const
Is the object static (not manipulable at all)?
Definition: object.cpp:106
void playSound(const Common::UString &sound, bool pitchVariance=false)
Play an object sound.
Definition: object.cpp:284
An NWScript object.
Area * _area
The area the object is currently in.
Definition: object.h:160
virtual void setPosition(float x, float y, float z)
Set the object&#39;s position within its area.
Definition: object.cpp:156
A struct within a GFF3.
Definition: gff3file.h:164
A handle to a sound channel.
Definition: types.h:35
uint32_t uint32
Definition: types.h:204
virtual void unloadModel()
Unload the object&#39;s model(s).
Definition: object.cpp:79
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:142
void loadSSF()
Load the object&#39;s sound set.
Definition: object.cpp:182
bool isUsable() const
Can the object be used by the PC?
Definition: object.cpp:110
bool _static
Is the object static?
Definition: object.h:155
void setArea(Area *)
Set the area this object is currently in.
Definition: object.cpp:126
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:35
Common::ScopedPtr< Aurora::SSFFile > _ssf
The object&#39;s sound set.
Definition: object.h:153
An object containing scripts.
virtual void show()
Show the object&#39;s model(s).
Definition: object.cpp:82
Location getLocation() const
Create a Location out of the object&#39;s area, position and orientation.
Definition: object.cpp:130
virtual bool click(Object *triggerer=0)
The object was clicked.
Definition: object.cpp:178
ObjectType getType() const
Return the exact type of the object.
Definition: object.cpp:72
Common::UString _description
The object&#39;s description.
Definition: object.h:148