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_NWN_OBJECTCONTAINER_H
26 #define ENGINES_NWN_OBJECTCONTAINER_H
27 
28 #include <list>
29 #include <map>
30 
31 #include "src/common/types.h"
32 
34 
35 #include "src/engines/nwn/types.h"
36 
37 namespace Engines {
38 
39 namespace NWN {
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 NWN::Object &target);
55 
56  bool operator()(NWN::Object *a, NWN::Object *b);
57 
58 private:
59  float xt, yt, zt;
60 
61  float getDistance(NWN::Object &a);
62 };
63 
65 public:
68 
69  void clearObjects();
70 
72  void addObject(NWN::Object &object);
74  void removeObject(NWN::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<NWN::Object *> ObjectList;
97  typedef std::map<ObjectType, ObjectList> ObjectMap;
98 
100 };
101 
102 } // End of namespace NWN
103 
104 } // End of namespace Engines
105 
106 #endif // ENGINES_NWN_OBJECTCONTAINER_H
static Creature * toCreature(Aurora::NWScript::Object *object)
static Module * toModule(Aurora::NWScript::Object *object)
Basic Neverwinter Nights type definitions.
static NWN::Object * toObject(::Aurora::NWScript::Object *object)
An area in Neverwinter Nights, holding all objects and room tiles within, as well as general area pro...
Definition: area.h:63
static Location * toLocation(Aurora::NWScript::EngineType *engineType)
std::map< ObjectType, ObjectList > ObjectMap
A class able to sort objects by distance to a target object.
static Door * toDoor(Aurora::NWScript::Object *object)
bool operator()(NWN::Object *a, NWN::Object *b)
static Creature * toPC(Aurora::NWScript::Object *object)
std::list< NWN::Object * > ObjectList
::Aurora::NWScript::ObjectSearch * findObjectsByType(ObjectType type) const
Return a search context to iterate over all objects of this type.
Low-level type definitions to handle fixed width types portably.
void addObject(NWN::Object &object)
Add an object to this container.
float getDistance(NWN::Object &a)
ObjectType
Object type, matches the bitfield in nwscript.nss.
Definition: types.h:36
static Placeable * toPlaceable(Aurora::NWScript::Object *object)
static Area * toArea(Aurora::NWScript::Object *object)
static Waypoint * toWaypoint(Aurora::NWScript::Object *object)
void removeObject(NWN::Object &object)
Remove an object from this container.
::Aurora::NWScript::Object * getFirstObjectByType(ObjectType type) const
Return the first object of this type.
An NWScript object container.
static Situated * toSituated(Aurora::NWScript::Object *object)
ObjectDistanceSort(const NWN::Object &target)