xoreos  0.0.5
area.cpp
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 #include "src/common/scopedptr.h"
26 #include "src/common/util.h"
27 #include "src/common/error.h"
28 #include "src/common/readstream.h"
29 #include "src/common/maths.h"
30 
31 #include "src/aurora/resman.h"
32 #include "src/aurora/gff3file.h"
33 #include "src/aurora/2dafile.h"
34 #include "src/aurora/2dareg.h"
35 
36 #include "src/graphics/graphics.h"
38 
40 
41 #include "src/sound/sound.h"
42 
44 
52 
53 namespace Engines {
54 
55 namespace KotOR2 {
56 
58  : distance(0.0f),
59  pitch(0.0f),
60  height(0.0f) {
61 }
62 
63 Area::Area(Module &module, const Common::UString &resRef)
65  _module(&module),
66  _resRef(resRef),
67  _visible(false),
68  _activeObject(0),
69  _highlightAll(false),
70  _triggersVisible(false),
71  _activeTrigger(0),
72  _walkmeshInvisible(true) {
73 
74  try {
75  load();
76  } catch (...) {
77  clear();
78  throw;
79  }
80 
81  // Tell the module that we exist
82  _module->addObject(*this);
83 }
84 
86  _module->removeObject(*this);
87 
88  hide();
89 
90  removeFocus();
91 
92  clear();
93 }
94 
95 void Area::load() {
96  loadLYT(); // Room layout
97  loadVIS(); // Room visibilities
98 
99  loadRooms();
100 
101  Aurora::GFF3File are(_resRef, Aurora::kFileTypeARE, MKTAG('A', 'R', 'E', ' '));
102  loadARE(are.getTopLevel());
103 
104  Aurora::GFF3File git(_resRef, Aurora::kFileTypeGIT, MKTAG('G', 'I', 'T', ' '));
105  loadGIT(git.getTopLevel());
106 }
107 
108 void Area::clear() {
109  for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
110  _module->removeObject(**o);
111 
112  _objects.clear();
113  _rooms.clear();
114  _triggers.clear();
115  _situatedObjects.clear();
116  _activeTrigger = 0;
117 }
118 
120  return _musicDayTrack;
121 }
122 
124  return _musicNightTrack;
125 }
126 
128  return _musicBattleTrack;
129 }
130 
132  _musicDayTrack = track;
133  _musicDay = TwoDAReg.get2DA("ambientmusic").getRow(track).getString("Resource");
134 }
135 
137  _musicNightTrack = track;
138  _musicNight = TwoDAReg.get2DA("ambientmusic").getRow(track).getString("Resource");
139 }
140 
142  _musicBattleTrack = track;
143 
145  const Aurora::TwoDAFile &ambientMusic = TwoDAReg.get2DA("ambientmusic");
146 
147  // Normal battle music
148  _musicBattle = ambientMusic.getRow(_musicBattleTrack).getString("Resource");
149 
150  // Battle stingers
151  Common::UString stinger[3];
152  stinger[0] = ambientMusic.getRow(_musicBattleTrack).getString("Stinger1");
153  stinger[1] = ambientMusic.getRow(_musicBattleTrack).getString("Stinger2");
154  stinger[2] = ambientMusic.getRow(_musicBattleTrack).getString("Stinger3");
155 
156  _musicBattleStinger.clear();
157  for (int i = 0; i < 3; i++)
158  if (!stinger[i].empty())
159  _musicBattleStinger.push_back(stinger[i]);
160  }
161 }
162 
166 }
167 
169  SoundMan.stopChannel(_ambientMusic);
170 }
171 
173  SoundMan.stopChannel(_ambientSound);
174 }
175 
178 
179  // TODO: Area::playAmbientMusic(): Day/Night
180  if (music.empty())
181  music = _musicDay;
182 
183  if (music.empty())
184  return;
185 
187 }
188 
191 
192  // TODO: Area::playAmbientSound(): Day/Night
193  if (sound.empty())
194  sound = _ambientDay;
195 
196  if (sound.empty())
197  return;
198 
200 }
201 
202 void Area::show() {
203  if (_visible)
204  return;
205 
206  GfxMan.lockFrame();
207 
208  // Show rooms
209  for (RoomList::iterator r = _rooms.begin(); r != _rooms.end(); ++r)
210  (*r)->show();
211 
212  // Show objects
213  for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
214  (*o)->show();
215 
216  GfxMan.unlockFrame();
217 
218  // Play music and sound
221 
222  _visible = true;
223 }
224 
225 void Area::hide() {
226  if (!_visible)
227  return;
228 
229  removeFocus();
230 
231  stopSound();
232 
233  GfxMan.lockFrame();
234 
235  // Hide objects
236  for (ObjectList::iterator o = _objects.begin(); o != _objects.end(); ++o)
237  (*o)->hide();
238 
239  // Hide rooms
240  for (RoomList::iterator r = _rooms.begin(); r != _rooms.end(); ++r)
241  (*r)->hide();
242 
243  GfxMan.unlockFrame();
244 
245  _visible = false;
246 }
247 
249  try {
251  if (!lyt)
252  throw Common::Exception("No such LYT");
253 
254  _lyt.load(*lyt);
255 
256  } catch (Common::Exception &e) {
257  e.add("Failed loading LYT \"%s\"", _resRef.c_str());
258  throw;
259  }
260 }
261 
263  try {
265  if (!vis)
266  throw Common::Exception("No such VIS");
267 
268  _vis.load(*vis);
269 
270  } catch (Common::Exception &e) {
271  e.add("Failed loading VIS \"%s\"", _resRef.c_str());
272  throw;
273  }
274 }
275 
277  // Tag
278  _tag = are.getString("Tag");
279 
280  // Name
281  _name = are.getString("Name");
282 
283  // Camera style
284  loadCameraStyle(are.getUint("CameraStyle"));
285 
286  // Scripts
287  readScripts(are);
288 }
289 
291  const Aurora::TwoDAFile &tda = TwoDAReg.get2DA("camerastyle");
292  const Aurora::TwoDARow &row = tda.getRow(id);
293  _cameraStyle.distance = row.getFloat("distance");
294  _cameraStyle.pitch = row.getFloat("pitch");
295  _cameraStyle.height = row.getFloat("height");
296 }
297 
299  if (git.hasField("AreaProperties"))
300  loadProperties(git.getStruct("AreaProperties"));
301 
302  if (git.hasField("WaypointList"))
303  loadWaypoints(git.getList("WaypointList"));
304 
305  if (git.hasField("Placeable List"))
306  loadPlaceables(git.getList("Placeable List"));
307 
308  if (git.hasField("Door List"))
309  loadDoors(git.getList("Door List"));
310 
311  if (git.hasField("Creature List"))
312  loadCreatures(git.getList("Creature List"));
313 
314  if (git.hasField("TriggerList"))
315  loadTriggers(git.getList("TriggerList"));
316 }
317 
319  // Ambient sound
320 
321  const Aurora::TwoDAFile &ambientSound = TwoDAReg.get2DA("ambientsound");
322 
323  uint32 ambientDay = props.getUint("AmbientSndDay" , Aurora::kStrRefInvalid);
324  uint32 ambientNight = props.getUint("AmbientSndNight", Aurora::kStrRefInvalid);
325 
326  _ambientDay = ambientSound.getRow(ambientDay ).getString("Resource");
327  _ambientNight = ambientSound.getRow(ambientNight).getString("Resource");
328 
329  uint32 ambientDayVol = CLIP<uint32>(props.getUint("AmbientSndDayVol" , 127), 0, 127);
330  uint32 ambientNightVol = CLIP<uint32>(props.getUint("AmbientSndNightVol", 127), 0, 127);
331 
332  _ambientDayVol = 1.25f * (1.0f - (1.0f / powf(5.0f, ambientDayVol / 127.0f)));
333  _ambientNightVol = 1.25f * (1.0f - (1.0f / powf(5.0f, ambientNightVol / 127.0f)));
334 
335  // TODO: PresetInstance0 - PresetInstance7
336 
337 
338  // Ambient music
339 
340  setMusicDayTrack (props.getUint("MusicDay" , Aurora::kStrRefInvalid));
341  setMusicNightTrack(props.getUint("MusicNight" , Aurora::kStrRefInvalid));
342 
343  // Battle music
344 
345  setMusicBattleTrack(props.getUint("MusicBattle", Aurora::kStrRefInvalid));
346 }
347 
349  const Aurora::LYTFile::RoomArray &rooms = _lyt.getRooms();
350  for (Aurora::LYTFile::RoomArray::const_iterator r = rooms.begin(); r != rooms.end(); ++r) {
351  _rooms.push_back(new Room(r->model, r->x, r->y, r->z));
352  }
353 }
354 
356  _objects.push_back(&object);
357  _module->addObject(object);
358 
359  if (!object.isStatic()) {
360  const std::list<uint32> &ids = object.getIDs();
361 
362  for (std::list<uint32>::const_iterator id = ids.begin(); id != ids.end(); ++id)
363  _objectMap.insert(std::make_pair(*id, &object));
364  }
365 
366  notifyObjectMoved(object);
367 }
368 
370  for (Aurora::GFF3List::const_iterator w = list.begin(); w != list.end(); ++w) {
371  Waypoint *waypoint = new Waypoint(**w);
372 
373  loadObject(*waypoint);
374  }
375 }
376 
378  for (Aurora::GFF3List::const_iterator p = list.begin(); p != list.end(); ++p) {
379  Placeable *placeable = new Placeable(**p);
380 
381  loadObject(*placeable);
382  _situatedObjects.push_back(placeable);
383  }
384 }
385 
387  for (Aurora::GFF3List::const_iterator d = list.begin(); d != list.end(); ++d) {
388  Door *door = new Door(*_module, **d);
389 
390  loadObject(*door);
391  _situatedObjects.push_back(door);
392  }
393 }
394 
396  for (Aurora::GFF3List::const_iterator c = list.begin(); c != list.end(); ++c) {
397  Creature *creature = new Creature(**c);
398 
399  loadObject(*creature);
400  }
401 }
402 
404  for (Aurora::GFF3List::const_iterator t = list.begin(); t != list.end(); ++t) {
405  Trigger *trigger = new Trigger(**t);
406 
407  loadObject(*trigger);
408  _triggers.push_back(trigger);
409  }
410 }
411 
412 void Area::addEvent(const Events::Event &event) {
413  _eventQueue.push_back(event);
414 }
415 
417  bool hasMove = false;
418  for (std::list<Events::Event>::const_iterator e = _eventQueue.begin();
419  e != _eventQueue.end(); ++e) {
420 
421  if (e->type == Events::kEventMouseMove) { // Moving the mouse
422  hasMove = true;
423  } else if (e->type == Events::kEventMouseDown) { // Clicking
424  if (e->button.button == SDL_BUTTON_LMASK) {
425  checkActive(e->button.x, e->button.y);
426  click(e->button.x, e->button.y);
427  }
428  } else if (e->type == Events::kEventKeyDown) { // Holding down TAB
429  if (e->key.keysym.sym == SDLK_TAB)
430  highlightAll(true);
431  } else if (e->type == Events::kEventKeyUp) { // Releasing TAB
432  if (e->key.keysym.sym == SDLK_TAB)
433  highlightAll(false);
434  }
435  }
436 
437  _eventQueue.clear();
438 
439  if (hasMove)
440  checkActive();
441 }
442 
444  const Graphics::Renderable *obj = GfxMan.getObjectAt(x, y);
445  if (!obj)
446  return 0;
447 
448  ObjectMap::iterator o = _objectMap.find(obj->getID());
449  if (o == _objectMap.end())
450  return 0;
451 
452  return o->second;
453 }
454 
456  if (object == _activeObject)
457  return;
458 
459  if (_activeObject)
460  _activeObject->leave();
461 
462  _activeObject = object;
463 
464  if (_activeObject)
465  _activeObject->enter();
466 }
467 
468 void Area::checkActive(int x, int y) {
469  if (_highlightAll)
470  return;
471 
473 
474  if ((x < 0) || (y < 0))
475  CursorMan.getPosition(x, y);
476 
477  setActive(getObjectAt(x, y));
478 }
479 
480 void Area::click(int x, int y) {
482 
483  KotOR2::Object *o = getObjectAt(x, y);
484  if (!o)
485  return;
486 
487  o->click(_module->getPC());
488  _module->clickObject(o);
489 }
490 
491 void Area::highlightAll(bool enabled) {
492  if (_highlightAll == enabled)
493  return;
494 
495  _highlightAll = enabled;
496 
497  for (ObjectMap::iterator o = _objectMap.begin(); o != _objectMap.end(); ++o)
498  if (o->second->isClickable())
499  o->second->highlight(enabled);
500 }
501 
503  if (_activeObject)
504  _activeObject->leave();
505 
506  _activeObject = 0;
507 }
508 
510  checkActive();
511 }
512 
513 float Area::evaluateElevation(float x, float y) {
514  Room *room = _module->getPC()->getRoom();
515 
516  float result = room ? room->evaluateElevation(x, y, true) : FLT_MIN;
517  if (result != FLT_MIN)
518  return result;
519 
520  if (room)
521  room->disableWalkmeshHighlight();
522 
523  for (RoomList::iterator r = _rooms.begin();
524  r != _rooms.end(); ++r) {
525  if (*r != room) {
526  result = (*r)->evaluateElevation(x, y, true);
527  if (result != FLT_MIN)
528  break;
529  }
530  }
531 
532  return result;
533 }
534 
535 bool Area::testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const {
536  for (std::list<Situated *>::const_iterator s = _situatedObjects.begin();
537  s != _situatedObjects.end(); ++s) {
538  if ((*s)->testCollision(orig, dest))
539  return true;
540  }
541  return false;
542 }
543 
546 
547  for (RoomList::iterator r = _rooms.begin();
548  r != _rooms.end(); ++r) {
549  (*r)->setWalkmeshInvisible(_walkmeshInvisible);
550  }
551 
552  for (std::list<Situated *>::iterator s = _situatedObjects.begin();
553  s != _situatedObjects.end(); ++s) {
554  (*s)->setWalkmeshInvisible(_walkmeshInvisible);
555  }
556 }
557 
560  for (std::vector<Trigger *>::const_iterator it = _triggers.begin();
561  it != _triggers.end();
562  ++it) {
563  (*it)->setVisible(_triggersVisible);
564  }
565 }
566 
567 void Area::evaluateTriggers(float x, float y) {
568  Trigger *trigger = 0;
569 
570  for (std::vector<Trigger *>::iterator it = _triggers.begin();
571  it != _triggers.end();
572  ++it) {
573  Trigger *t = *it;
574  if (t->contains(x, y)) {
575  trigger = t;
576  break;
577  }
578  }
579 
580  if (_activeTrigger != trigger) {
581  if (_activeTrigger)
583  _activeTrigger = trigger;
584  if (_activeTrigger)
586  }
587 }
588 
590  GfxMan.pauseAnimations();
591 
592  for (RoomList::iterator r = _rooms.begin();
593  r != _rooms.end(); ++r) {
594  if (!(*r)->isVisible())
595  (*r)->show();
596  }
597 
598  for (ObjectList::iterator o = _objects.begin();
599  o != _objects.end(); ++o) {
600  if (!(*o)->isVisible())
601  (*o)->show();
602  }
603 
604  GfxMan.resumeAnimations();
605 }
606 
608  float x, y, z;
609  o.getPosition(x, y, z);
610  o.setRoom(getRoomAt(x, y));
611 }
612 
614  Creature *pc = _module->getPC();
615 
616  const Room *prevPCRoom = pc->getRoom();
617  notifyObjectMoved(*pc);
618  const Room *pcRoom = pc->getRoom();
619 
620  if (pcRoom == prevPCRoom)
621  return;
622 
623  std::vector<Common::UString> visRooms;
624  if (pcRoom) {
625  visRooms.push_back(pcRoom->getResRef());
626 
627  const std::vector<Common::UString> va = _vis.getVisibilityArray(pcRoom->getResRef());
628  for (std::vector<Common::UString>::const_iterator v = va.begin();
629  v != va.end(); ++v) {
630  Common::UString lcResRef(v->toLower());
631  if (std::find(visRooms.begin(), visRooms.end(), lcResRef) == visRooms.end())
632  visRooms.push_back(lcResRef);
633  }
634  }
635 
636  GfxMan.pauseAnimations();
637 
638  for (RoomList::iterator r = _rooms.begin();
639  r != _rooms.end(); ++r) {
640  bool visible = std::find(visRooms.begin(), visRooms.end(), (*r)->getResRef()) != visRooms.end();
641  if (visible) {
642  if (!(*r)->isVisible())
643  (*r)->show();
644  } else if ((*r)->isVisible())
645  (*r)->hide();
646  }
647 
648  for (ObjectList::iterator o = _objects.begin();
649  o != _objects.end(); ++o) {
650  const Room *objRoom = (*o)->getRoom();
651  bool visible = objRoom && objRoom->isVisible();
652  if (visible) {
653  if (!(*o)->isVisible())
654  (*o)->show();
655  } else if ((*o)->isVisible())
656  (*o)->hideSoft();
657  }
658 
659  GfxMan.resumeAnimations();
660 }
661 
662 void Area::getCameraStyle(float &distance, float &pitch, float &height) const {
663  distance = _cameraStyle.distance;
664  pitch = _cameraStyle.pitch;
665  height = _cameraStyle.height;
666 }
667 
668 const std::vector<Common::UString> &Area::getRoomsVisibleFrom(const Common::UString &room) const {
669  return _vis.getVisibilityArray(room);
670 }
671 
673  return _activeObject;
674 }
675 
677  for (ObjectList::iterator o = _objects.begin();
678  o != _objects.end(); ++o) {
679  if ((*o)->getTag().stricmp(tag) == 0)
680  return *o;
681  }
682  return 0;
683 }
684 
685 Room *Area::getRoomAt(float x, float y) const {
686  for (RoomList::const_iterator r = _rooms.begin();
687  r != _rooms.end(); ++r) {
688  if ((*r)->evaluateElevation(x, y) != FLT_MIN)
689  return *r;
690  }
691  return 0;
692 }
693 
694 } // End of namespace KotOR2
695 
696 } // End of namespace Engines
uint32 _musicNightTrack
Music track ID that plays by night.
Definition: area.h:157
Class to hold the two-dimensional array of a 2DA file.
Definition: 2dafile.h:124
void addObject(KotOR2::Object &object)
Add an object to this container.
std::list< Events::Event > _eventQueue
The event queue.
Definition: area.h:188
Handling version V3.2/V3.3 of BioWare&#39;s GFFs (generic file format).
#define ResMan
Shortcut for accessing the sound manager.
Definition: resman.h:557
#define MKTAG(a0, a1, a2, a3)
A wrapper macro used around four character constants, like &#39;DATA&#39;, to ensure portability.
Definition: endianness.h:140
float _ambientDayVol
Day ambient sound volume.
Definition: area.h:167
void loadCreatures(const Aurora::GFF3List &list)
Definition: area.cpp:395
bool isStatic() const
Is the object static (not manipulable at all)?
Definition: object.cpp:91
KotOR2::Object * getObjectByTag(const Common::UString &tag)
Definition: area.cpp:676
void add(const char *s,...) GCC_PRINTF(2
Definition: error.cpp:58
A room within a Star Wars: Knights of the Old Republic II - The Sith Lords area.
A creature in a Star Wars: Knights of the Old Republic II - The Sith Lords area.
void disableWalkmeshHighlight()
Definition: room.cpp:74
The global graphics manager.
virtual void getPosition(float &x, float &y, float &z) const
Return the object&#39;s position within its area.
Definition: object.cpp:107
const Common::UString & getString(size_t column) const
Return the contents of a cell as a string.
Definition: 2dafile.cpp:59
Module * _module
The module this area is in.
Definition: area.h:148
Room * getRoom()
Get a room the object is in.
Definition: object.cpp:144
void stopSound()
Stop all sounds.
Definition: area.cpp:163
A class holding an UTF-8 string.
Definition: ustring.h:48
Sound::ChannelHandle _ambientSound
Sound handle of the currently playing sound.
Definition: area.h:172
bool _highlightAll
Are we currently highlighting all objects?
Definition: area.h:186
Common::UString _resRef
The area&#39;s resref (resource ID).
Definition: area.h:150
bool hasField(const Common::UString &field) const
Does this specific field exist?
Definition: gff3file.cpp:400
Mathematical helpers.
bool _walkmeshInvisible
Definition: area.h:199
virtual bool click(Object *triggerer=0)
The object was clicked.
Definition: object.cpp:161
Common::UString _musicNight
Music that plays by night.
Definition: area.h:161
void evaluateTriggers(float x, float y)
Definition: area.cpp:567
void setMusicNightTrack(uint32 track)
Set the music track ID playing by night.
Definition: area.cpp:136
const GFF3Struct & getTopLevel() const
Returns the top-level struct.
Definition: gff3file.cpp:91
void show()
Show the object&#39;s model(s).
Definition: area.cpp:202
uint64 getUint(const Common::UString &field, uint64 def=0) const
Definition: gff3file.cpp:436
Common::UString _ambientDay
Ambient sound that plays by day.
Definition: area.h:153
void notifyCameraMoved()
Definition: area.cpp:509
Area data, room layout.
Definition: types.h:176
virtual void enter()
The cursor entered the object.
Definition: object.cpp:152
std::list< Situated * > _situatedObjects
Definition: area.h:200
Aurora::LYTFile _lyt
The area&#39;s layout description.
Definition: area.h:175
The context holding a Star Wars: Knights of the Old Republic II - The Sith Lords area.
const std::vector< Common::UString > & getVisibilityArray(const Common::UString &room) const
Return the visibility array for a given room.
Definition: visfile.cpp:118
Mouse was moved.
Definition: types.h:48
Exception that provides a stack of explanations.
Definition: error.h:36
A simple scoped smart pointer template.
bool testCollision(const glm::vec3 &orig, const glm::vec3 &dest) const
Definition: area.cpp:535
SDL_Event Event
Definition: types.h:42
void load(Common::SeekableReadStream &vis)
Load a VIS file.
Definition: visfile.cpp:45
void removeObject(KotOR2::Object &object)
Remove an object from this container.
A placeable in a Star Wars: Knights of the Old Republic II - The Sith Lords area. ...
Mouse button was pressed.
Definition: types.h:49
void setActive(KotOR2::Object *object)
Definition: area.cpp:455
Keyboard key was pressed.
Definition: types.h:46
Aurora::VISFile _vis
The area&#39;s inter-room visibility description.
Definition: area.h:176
A door in a Star Wars: Knights of the Old Republic II - The Sith Lords area.
void loadTriggers(const Aurora::GFF3List &list)
Definition: area.cpp:403
Basic exceptions to throw.
const char * c_str() const
Return the (utf8 encoded) string data.
Definition: ustring.cpp:249
const RoomArray & getRooms() const
Get all rooms in this layout.
Definition: lytfile.cpp:202
uint32 _musicDayTrack
Music track ID that plays by day.
Definition: area.h:156
void loadDoors(const Aurora::GFF3List &list)
Definition: area.cpp:386
Common::UString _name
The object&#39;s display name.
Definition: object.h:129
Utility templates and functions.
float evaluateElevation(float x, float y, bool highlight=false)
Definition: room.cpp:64
void setMusicDayTrack(uint32 track)
Set the music track ID playing by day.
Definition: area.cpp:131
ObjectList _objects
List of all objects in the area.
Definition: area.h:180
Handling BioWare&#39;s 2DAs (two-dimensional array).
const std::vector< Common::UString > & getRoomsVisibleFrom(const Common::UString &room) const
Definition: area.cpp:668
void toggleWalkmesh()
Definition: area.cpp:544
void loadCameraStyle(uint32 id)
Definition: area.cpp:290
void stopAmbientSound()
Stop the ambient sound.
Definition: area.cpp:172
Common::Mutex _mutex
Mutex securing access to the area.
Definition: area.h:190
bool runScript(Script script, const Aurora::NWScript::ObjectReference owner=Aurora::NWScript::ObjectReference(), const Aurora::NWScript::ObjectReference triggerer=Aurora::NWScript::ObjectReference())
Definition: container.cpp:150
ObjectMap _objectMap
Map of all non-static objects in the area.
Definition: area.h:181
A GFF (generic file format) V3.2/V3.3 file, found in all Aurora games except Sonic Chronicles: The Da...
Definition: gff3file.h:85
Creature * getPC()
Return the currently playing PC.
Definition: module.cpp:147
static const uint32 kStrRefInvalid
Definition: types.h:444
std::vector< Room > RoomArray
Definition: lytfile.h:78
void hide()
Hide the object&#39;s model(s).
Definition: area.cpp:225
void playAmbientSound(Common::UString sound="")
Play the specified sound (or the area&#39;s default) as ambient sound.
Definition: area.cpp:189
Common::UString _ambientNight
Ambient sound that plays by night.
Definition: area.h:154
void stopAmbientMusic()
Stop the ambient music.
Definition: area.cpp:168
void loadPlaceables(const Aurora::GFF3List &list)
Definition: area.cpp:377
The global sound manager, handling all sound output.
bool empty() const
Is the string empty?
Definition: ustring.cpp:245
uint32 _musicBattleTrack
Music track ID that plays in battle.
Definition: area.h:158
#define TwoDAReg
Shortcut for accessing the 2da registry.
Definition: 2dareg.h:101
void loadWaypoints(const Aurora::GFF3List &list)
Definition: area.cpp:369
void toggleTriggers()
Definition: area.cpp:558
void highlightAll(bool enabled)
Definition: area.cpp:491
uint32 getMusicDayTrack() const
Return the music track ID playing by day.
Definition: area.cpp:119
void click(int x, int y)
Definition: area.cpp:480
RoomList _rooms
All rooms in the area.
Definition: area.h:178
#define SoundMan
Shortcut for accessing the sound manager.
Definition: sound.h:293
StackException Exception
Definition: error.h:59
The global 2DA registry.
void setRoom(Room *room)
Set a room the object is in.
Definition: object.cpp:148
#define CursorMan
Shortcut for accessing the cursor manager.
Definition: cursorman.h:129
Basic reading stream interfaces.
void loadGIT(const Aurora::GFF3Struct &git)
Definition: area.cpp:298
std::vector< const GFF3Struct * > GFF3List
Definition: types.h:449
Convenience class that locks a mutex on creation and unlocks it on destruction.
Definition: mutex.h:71
The context needed to run a Star Wars: Knights of the Old Republic II - The Sith Lords module...
float evaluateElevation(float x, float y)
Definition: area.cpp:513
The Aurora cursor manager.
bool _triggersVisible
Definition: area.h:194
Sound::ChannelHandle playSound(const Common::UString &sound, Sound::SoundType soundType, bool loop, float volume, bool pitchVariance)
Play this sound resource.
Definition: util.cpp:81
void addEvent(const Events::Event &event)
Add a single event for consideration into the area event queue.
Definition: area.cpp:412
void loadProperties(const Aurora::GFF3Struct &props)
Definition: area.cpp:318
An object that can be displayed by the graphics manager.
Definition: renderable.h:42
std::vector< Trigger * > _triggers
.— Triggers
Definition: area.h:193
const GFF3List & getList(const Common::UString &field) const
Definition: gff3file.cpp:741
uint32 getID() const
Get the object&#39;s unique ID.
Definition: renderable.cpp:86
Fake value for an area object.
Definition: types.h:50
const TwoDARow & getRow(size_t row) const
Get a row.
Definition: 2dafile.cpp:421
Dynamic area data, GFF.
Definition: types.h:89
void setMusicBattleTrack(uint32 track)
Set the music track ID playing in battle.
Definition: area.cpp:141
Common::UString getResRef() const
Definition: room.cpp:60
void processEventQueue()
Process the current event queue.
Definition: area.cpp:416
void clear()
Definition: ptrlist.h:47
A struct within a GFF3.
Definition: gff3file.h:164
Common::UString _musicDay
Music that plays by day.
Definition: area.h:160
bool _visible
Is the area currently visible?
Definition: area.h:170
uint32_t uint32
Definition: types.h:204
const GFF3Struct & getStruct(const Common::UString &field) const
Definition: gff3file.cpp:728
void loadARE(const Aurora::GFF3Struct &are)
Definition: area.cpp:276
Common::UString _tag
Definition: object.h:56
Static area data, GFF.
Definition: types.h:81
KotOR2::Object * _activeObject
The currently active (highlighted) object.
Definition: area.h:184
#define FLT_MIN
Definition: maths.h:43
void loadObject(KotOR2::Object &object)
Definition: area.cpp:355
void playAmbientMusic(Common::UString music="")
Play the specified music (or the area&#39;s default) as ambient music.
Definition: area.cpp:176
Common::UString getString(const Common::UString &field, const Common::UString &def="") const
Definition: gff3file.cpp:527
uint32 getMusicBattleTrack() const
Return the music track ID playing in battle.
Definition: area.cpp:127
Sound effect.
Definition: types.h:45
KotOR2::Object * getActiveObject()
Definition: area.cpp:672
Generic Aurora engines utility functions.
void readScripts(const Aurora::GFF3Struct &gff)
Definition: container.cpp:134
Sound::ChannelHandle _ambientMusic
Sound handle of the currently playing music.
Definition: area.h:173
void notifyObjectMoved(Object &o)
Definition: area.cpp:607
A waypoint in a Star Wars: Knights of the Old Republic II - The Sith Lords area.
bool isVisible() const
Definition: room.cpp:94
virtual void leave()
The cursor left the object.
Definition: object.cpp:155
uint32 getMusicNightTrack() const
Return the music track ID playing by night.
Definition: area.cpp:123
A row within a 2DA file.
Definition: 2dafile.h:61
KotOR2::Object * getObjectAt(int x, int y)
Definition: area.cpp:443
void checkActive(int x=-1, int y=-1)
Definition: area.cpp:468
Keyboard key was released.
Definition: types.h:47
void load(Common::SeekableReadStream &lyt)
Load a LYT file.
Definition: lytfile.cpp:56
float _ambientNightVol
Night ambient sound volume.
Definition: area.h:168
Area(Module &module, const Common::UString &resRef)
Definition: area.cpp:63
An object that can be displayed by the graphics manager.
void clickObject(Object *object)
Definition: module.cpp:412
Room * getRoomAt(float x, float y) const
Definition: area.cpp:685
void notifyPCMoved()
Definition: area.cpp:613
#define GfxMan
Shortcut for accessing the graphics manager.
Definition: graphics.h:299
void removeFocus()
Forcibly remove the focus from the currently highlighted object.
Definition: area.cpp:502
The global resource manager for Aurora resources.
CameraStyle _cameraStyle
&#39;—
Definition: area.h:198
float getFloat(size_t column) const
Return the contents of a cell as a float.
Definition: 2dafile.cpp:91
void getCameraStyle(float &distance, float &pitch, float &height) const
Definition: area.cpp:662
Common::UString _musicBattle
Music that plays in battle.
Definition: area.h:162
Area data, room visibilities.
Definition: types.h:177
Trigger * _activeTrigger
Definition: area.h:195
std::vector< Common::UString > _musicBattleStinger
Battle music stingers.
Definition: area.h:165
bool contains(float x, float y) const
Definition: trigger.cpp:51