xoreos  0.0.5
objectcontainer.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_OBJECTCONTAINER_H
26 #define ENGINES_NWN2_OBJECTCONTAINER_H
27 
28 #include <list>
29 #include <map>
30 
31 #include "src/common/types.h"
32 
34 
35 #include "src/engines/nwn2/types.h"
36 
37 namespace Engines {
38 
39 namespace NWN2 {
40 
41 class Object;
42 class Module;
43 class Area;
44 class Waypoint;
45 class Situated;
46 class Placeable;
47 class Door;
48 class Creature;
49 class Location;
50 
53 public:
54  ObjectDistanceSort(const NWN2::Object &target);
55 
57 
58 private:
59  float xt, yt, zt;
60 
61  float getDistance(NWN2::Object &a);
62 };
63 
65 public:
68 
69  void clearObjects();
70 
72  void addObject(NWN2::Object &object);
74  void removeObject(NWN2::Object &object);
75 
78 
81 
83 
84  static Module *toModule (Aurora::NWScript::Object *object);
85  static Area *toArea (Aurora::NWScript::Object *object);
89  static Door *toDoor (Aurora::NWScript::Object *object);
91  static Creature *toPC (Aurora::NWScript::Object *object);
92 
94 
95 private:
96  typedef std::list<NWN2::Object *> ObjectList;
97  typedef std::map<ObjectType, ObjectList> ObjectMap;
98 
100 };
101 
102 } // End of namespace NWN2
103 
104 } // End of namespace Engines
105 
106 #endif // ENGINES_NWN2_OBJECTCONTAINER_H
A class able to sort objects by distance to a target object.
static NWN2::Object * toObject(::Aurora::NWScript::Object *object)
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
static Creature * toCreature(Aurora::NWScript::Object *object)
float getDistance(NWN2::Object &a)
An object within a NWN2 area.
Definition: object.h:58
std::map< ObjectType, ObjectList > ObjectMap
void removeObject(NWN2::Object &object)
Remove an object from this container.
Basic Neverwinter Nights 2 type definitions.
static Location * toLocation(Aurora::NWScript::EngineType *engineType)
static Situated * toSituated(Aurora::NWScript::Object *object)
static Module * toModule(Aurora::NWScript::Object *object)
::Aurora::NWScript::ObjectSearch * findObjectsByType(ObjectType type) const
Return a search context to iterate over all objects of this type.
static Placeable * toPlaceable(Aurora::NWScript::Object *object)
void addObject(NWN2::Object &object)
Add an object to this container.
bool operator()(NWN2::Object *a, NWN2::Object *b)
Low-level type definitions to handle fixed width types portably.
::Aurora::NWScript::Object * getFirstObjectByType(ObjectType type) const
Return the first object of this type.
std::list< NWN2::Object * > ObjectList
static Door * toDoor(Aurora::NWScript::Object *object)
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:35
ObjectDistanceSort(const NWN2::Object &target)
static Area * toArea(Aurora::NWScript::Object *object)
An NWScript object container.
static Creature * toPC(Aurora::NWScript::Object *object)
static Waypoint * toWaypoint(Aurora::NWScript::Object *object)