xoreos  0.0.5
area.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_AREA_H
26 #define ENGINES_KOTOR_AREA_H
27 
28 #include <vector>
29 #include <list>
30 #include <map>
31 
32 #include "src/common/ptrlist.h"
33 #include "src/common/ustring.h"
34 #include "src/common/mutex.h"
35 
36 #include "src/aurora/types.h"
37 #include "src/aurora/lytfile.h"
38 #include "src/aurora/visfile.h"
39 
40 #include "src/sound/types.h"
41 
42 #include "src/events/types.h"
43 #include "src/events/notifyable.h"
44 
47 
48 namespace Engines {
49 
50 namespace KotOR {
51 
52 class Module;
53 class Room;
54 class Situated;
55 class Creature;
56 
65 class Area : public KotOR::Object, public Events::Notifyable {
66 public:
67  Area(Module &module, const Common::UString &resRef);
68  ~Area();
69 
70  // General properties
71 
73  const Common::UString &getResRef();
74 
75  // Minimap
76 
78  int getNorthAxis();
80  void getMapPoint1(float &x, float &y);
82  void getMapPoint2(float &x, float &y);
84  void getWorldPoint1(float &x, float &y);
86  void getWorldPoint2(float &x, float &y);
87 
88  // Visibility
89 
90  void show();
91  void hide();
92 
93  // Music/Sound
94 
95  uint32 getMusicDayTrack () const;
96  uint32 getMusicNightTrack () const;
97  uint32 getMusicBattleTrack() const;
98 
99  void setMusicDayTrack (uint32 track);
100  void setMusicNightTrack (uint32 track);
101  void setMusicBattleTrack(uint32 track);
102 
103  void stopSound();
104  void stopAmbientMusic();
105  void stopAmbientSound();
106 
108  void playAmbientMusic(Common::UString music = "");
110  void playAmbientSound(Common::UString sound = "");
111 
112  // Events
113 
115  void addEvent(const Events::Event &event);
117  void processEventQueue();
118 
120  void removeFocus();
121 
122  // Walkmesh
123  float evaluateElevation(Object *object, float x, float y, bool doHighlight = true);
124  bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const;
125  void toggleWalkmesh();
126 
128  void toggleTriggers();
129  void evaluateTriggers(float x, float y);
131 
132  void showAllRooms();
133 
134  void notifyObjectMoved(Object &o);
135  void notifyPCMoved();
136 
137  void getCameraStyle(float &distance, float &pitch, float &height) const;
138  const std::vector<Common::UString> &getRoomsVisibleFrom(const Common::UString &room) const;
141 
142  void processCreaturesActions(float dt);
143 
144  void removeObject(KotOR::Object *object);
145 
146 
147 protected:
148  void notifyCameraMoved();
149 
150 
151 private:
152  struct CameraStyle {
153  float distance;
154  float pitch;
155  float height;
156 
157  CameraStyle();
158  };
159 
161 
163  typedef std::map<uint32, KotOR::Object *> ObjectMap;
164 
165 
167 
170 
173 
177 
181 
183  std::vector<Common::UString> _musicBattleStinger;
184 
187 
188  bool _visible;
189 
193 
196 
199 
201 
204 
205  std::vector<Creature *> _creatures;
206 
209 
211 
212  std::list<Events::Event> _eventQueue;
213 
215 
217  std::vector<Trigger *> _triggers;
221 
224  std::list<Situated *> _situatedObjects;
225 
226 
227  // Loading helpers
228 
229  void clear();
230  void load();
231 
232  void loadLYT();
233  void loadVIS();
234 
235  void loadARE(const Aurora::GFF3Struct &are);
236  void loadGIT(const Aurora::GFF3Struct &git);
237 
238  void loadCameraStyle(uint32 id);
239 
240  void loadRooms();
241 
242  void loadProperties(const Aurora::GFF3Struct &props);
243 
244  void loadObject(KotOR::Object &object);
245 
246  void loadWaypoints (const Aurora::GFF3List &list);
247  void loadPlaceables(const Aurora::GFF3List &list);
248  void loadDoors (const Aurora::GFF3List &list);
249  void loadCreatures (const Aurora::GFF3List &list);
250  void loadSounds (const Aurora::GFF3List &list);
251  void loadTriggers (const Aurora::GFF3List &list);
252 
253  void unload();
254 
255  // Highlight / active helpers
256 
257  void checkActive(int x = -1, int y = -1);
258  void setActive(KotOR::Object *object);
259  KotOR::Object *getObjectAt(int x, int y);
260 
261  void highlightAll(bool enabled);
262 
263  void click(int x, int y);
264 
265  Room *getRoomAt(float x, float y) const;
266 
267 
268  friend class Console;
269  friend class ActionExecutor;
270 };
271 
272 } // End of namespace KotOR
273 
274 } // End of namespace Engines
275 
276 #endif // ENGINES_KOTOR_AREA_H
void loadSounds(const Aurora::GFF3List &list)
Definition: area.cpp:456
Common::UString _musicDay
Music that plays by day.
Definition: area.h:178
Basic event types.
void notifyCameraMoved()
Definition: area.cpp:561
void stopAmbientSound()
Stop the ambient sound.
Definition: area.cpp:176
void loadCameraStyle(uint32 id)
Definition: area.cpp:330
const std::vector< Common::UString > & getRoomsVisibleFrom(const Common::UString &room) const
Definition: area.cpp:720
std::vector< Creature * > _creatures
Definition: area.h:205
KotOR::Object * getObjectByTag(const Common::UString &tag)
Definition: area.cpp:728
Common::PtrList< Room > RoomList
Definition: area.h:160
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:180
void processEventQueue()
Process the current event queue.
Definition: area.cpp:468
void loadPlaceables(const Aurora::GFF3List &list)
Definition: area.cpp:420
A class holding an UTF-8 string.
Definition: ustring.h:48
uint32 _musicDayTrack
Music track ID that plays by day.
Definition: area.h:174
Aurora::VISFile _vis
The area&#39;s inter-room visibility description.
Definition: area.h:198
void toggleWalkmesh()
Definition: area.cpp:596
void playAmbientSound(Common::UString sound="")
Play the specified sound (or the area&#39;s default) as ambient sound.
Definition: area.cpp:193
An LYT, BioWare&#39;s Layout Format.
Definition: lytfile.h:55
void loadObject(KotOR::Object &object)
Definition: area.cpp:398
float _worldPt1X
Definition: area.h:190
void getMapPoint1(float &x, float &y)
Get the first map point.
Definition: area.cpp:210
Common::Mutex _mutex
Mutex securing access to the area.
Definition: area.h:214
Area(Module &module, const Common::UString &resRef)
Definition: area.cpp:66
Common::UString _musicNight
Music that plays by night.
Definition: area.h:179
Basic sound types.
RoomList _rooms
All rooms in the area.
Definition: area.h:200
Common::UString _resRef
The area&#39;s resref (resource ID).
Definition: area.h:168
void getCameraStyle(float &distance, float &pitch, float &height) const
Definition: area.cpp:714
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:135
ObjectMap _objectMap
Map of all non-static objects in the area.
Definition: area.h:203
void loadWaypoints(const Aurora::GFF3List &list)
Definition: area.cpp:412
void loadDoors(const Aurora::GFF3List &list)
Definition: area.cpp:429
void showAllRooms()
&#39;—
Definition: area.cpp:641
SDL_Event Event
Definition: types.h:42
A list storing pointer to objects, with automatic deletion.
const Common::UString & getResRef()
Return the area&#39;s resref (resource ID).
Trigger in a Star Wars: Knights of the Old Republic area.
bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const
Definition: area.cpp:587
bool _walkmeshInvisible
Definition: area.h:223
uint32 _musicBattleTrack
Music track ID that plays in battle.
Definition: area.h:176
A mutex.
Definition: mutex.h:40
void highlightAll(bool enabled)
Definition: area.cpp:543
void processCreaturesActions(float dt)
Definition: area.cpp:737
Module * _module
The module this area is in.
Definition: area.h:166
void getWorldPoint1(float &x, float &y)
Get the first world point.
Definition: area.cpp:220
void hide()
Hide the object&#39;s model(s).
Definition: area.cpp:253
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:554
Sound::ChannelHandle _ambientMusic
Sound handle of the currently playing music.
Definition: area.h:195
void evaluateTriggers(float x, float y)
Definition: area.cpp:619
CameraStyle _cameraStyle
&#39;—
Definition: area.h:222
void setMusicBattleTrack(uint32 track)
Set the music track ID playing in battle.
Definition: area.cpp:145
void loadGIT(const Aurora::GFF3Struct &git)
Definition: area.cpp:338
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:172
Room * getRoomAt(float x, float y) const
Definition: area.cpp:771
uint32 _musicNightTrack
Music track ID that plays by night.
Definition: area.h:175
bool _triggersVisible
Definition: area.h:218
Handling BioWare&#39;s VISs (Visibility files).
A class that can be notified by the NotificationManager.
void stopSound()
Stop all sounds.
Definition: area.cpp:167
Common::UString _ambientNight
Ambient sound that plays by night.
Definition: area.h:172
An area in Star Wars: Knights of the Old Republic, holding all objects and rooms within, as well as general area properties like the current background music and ambient sounds.
Definition: area.h:65
void setActive(KotOR::Object *object)
Definition: area.cpp:507
float _worldPt2X
Definition: area.h:190
KotOR::Object * getActiveObject()
Definition: area.cpp:724
Aurora::LYTFile _lyt
The area&#39;s layout description.
Definition: area.h:197
bool _highlightAll
Are we currently highlighting all objects?
Definition: area.h:210
Common::UString _displayName
The area&#39;s localized display name.
Definition: area.h:169
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
bool _visible
Is the area currently visible?
Definition: area.h:188
A VIS, BioWare&#39;s Visibility Format.
Definition: visfile.h:52
KotOR::Object * getObjectAt(int x, int y)
Definition: area.cpp:495
Sound::ChannelHandle _ambientSound
Sound handle of the currently playing sound.
Definition: area.h:194
Unicode string handling.
void getMapPoint2(float &x, float &y)
Get the second map point.
Definition: area.cpp:215
Thread mutex classes.
uint32 getMusicBattleTrack() const
Return the music track ID playing in battle.
Definition: area.cpp:131
Basic type definitions to handle files used in BioWare&#39;s Aurora engine.
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:464
void toggleTriggers()
.— Triggers
Definition: area.cpp:610
void notifyPCMoved()
Definition: area.cpp:665
void loadTriggers(const Aurora::GFF3List &list)
Definition: area.cpp:447
int getNorthAxis()
Get the north axis id.
Definition: area.cpp:206
A struct within a GFF3.
Definition: gff3file.h:164
std::list< Events::Event > _eventQueue
The event queue.
Definition: area.h:212
A handle to a sound channel.
Definition: types.h:35
float _ambientNightVol
Night ambient sound volume.
Definition: area.h:186
uint32_t uint32
Definition: types.h:204
float evaluateElevation(Object *object, float x, float y, bool doHighlight=true)
Definition: area.cpp:565
Trigger * _activeTrigger
Definition: area.h:219
void show()
Show the object&#39;s model(s).
Definition: area.cpp:230
void click(int x, int y)
Definition: area.cpp:532
std::vector< Common::UString > _musicBattleStinger
Battle music stingers.
Definition: area.h:183
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:123
KotOR::Object * _activeObject
The currently active (highlighted) object.
Definition: area.h:208
float _worldPt1Y
Definition: area.h:190
void removeObject(KotOR::Object *object)
Definition: area.cpp:744
std::vector< Trigger * > _triggers
.— Triggers
Definition: area.h:217
Common::PtrList< KotOR::Object > ObjectList
Definition: area.h:162
An object in a Star Wars: Knights of the Old Republic area.
float _worldPt2Y
Definition: area.h:190
void loadCreatures(const Aurora::GFF3List &list)
Definition: area.cpp:438
ObjectList _objects
List of all objects in the area.
Definition: area.h:202
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:127
void getWorldPoint2(float &x, float &y)
Get the second world point.
Definition: area.cpp:225
float _ambientDayVol
Day ambient sound volume.
Definition: area.h:185
Common::UString _ambientDay
Ambient sound that plays by day.
Definition: area.h:171
Common::UString _musicBattle
Music that plays in battle.
Definition: area.h:180
void loadProperties(const Aurora::GFF3Struct &props)
Definition: area.cpp:361
void notifyObjectMoved(Object &o)
Definition: area.cpp:659
void loadARE(const Aurora::GFF3Struct &are)
Definition: area.cpp:304
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:140
std::map< uint32, KotOR::Object * > ObjectMap
Definition: area.h:163
void checkActive(int x=-1, int y=-1)
Definition: area.cpp:520
std::list< Situated * > _situatedObjects
Definition: area.h:224
Handling BioWare&#39;s LYTs (Layout files).