2 * This file includes the base class definition for entity kingdoms.
3 * Kingdoms group entities roughly by their most basic similiarities.
4 * The name 'Kingdom' is derived from the biological term.
6 * Copyright (C) 2008 Hermann Walth
8 * This file is part of OpenStranded
10 * OpenStranded is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
15 * OpenStranded is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with OpenStranded. If not, see <http://www.gnu.org/licenses/>.
24 #ifndef STRANDED_KINGDOM_HH
25 #define STRANDED_KINGDOM_HH
34 typedef unsigned int ID
;
38 * This is a base class for all kingdoms
39 * Originally implemented kingdoms were, roughly summarized, the following:
40 * Units as the only mobile and intelligent (or controllable) entities,
41 * Items as storable tools or resources,
42 * Objects as immobile structures, flora, rocks or similiar, and
43 * Infos as meta-information for technical purposes
44 * The OpenStranded Kingdom system is, however, designed to make it possible
45 * to implement new kingdoms at will.
53 * Kingdoms manage all their entities and types
54 * with pointers in local lists (STL Maps)
55 * where they are mapped to certain IDs.
56 * Using pointers may not be optimal OOP,
57 * but other methods aren't as efficient here.
59 std::map
<ID
, Entity
*> entityList
;
60 std::map
<ID
, Type
*> typeList
;
66 * The constructor, with the kingdom name as argument
68 Kingdom (const char *name
);
71 * Entities and Types are most likely to be allocated on the heap,
72 * so this destructor is used to free them again
78 * Looks up a certain entity from the kingdom's list by its ID
84 * Looks up a certain type from the kingdom's list by its ID
90 * Checks whether an entity with a certain ID exists
93 entityExists (ID entity
);
96 * Checks whether a type with a certain ID exists
102 * Append an entity to the list, automatically assigning an ID
103 * which is by 1 higher than the currently highest entity ID
106 appendEntity (ID type
);
109 * Insert an entity into a specific position of the list, assigning
110 * the specified ID to it
113 insertEntity (ID type
, ID entity
);
116 * TypeIDs need to be certain and definite towards the outside,
117 * so there is only an insertType method defining a certain ID
120 insertType (const char* name
, ID type
);
123 insertType (ID type
);
126 * These are some virtual functions used by other methods.
127 * They differ from kingdom to kingdom.
128 * Basically, they should just implement the
129 * entity's and type's constructors/destructors for this kingdom
132 createEntity (ID type
);
135 destroyEntity (Entity
*entity
);
138 createType (const char* name
);
141 destroyType (Type
*type
);
144 * Static class members
147 static std::map
<ID
, Kingdom
*> kingdomList
;
153 uninitKingdomList ();
156 #endif /* STRANDED_KINGDOM_HH */