Thrive
compound_registry.h
1 #pragma once
2 
3 #include <boost/range/adaptor/map.hpp>
4 
5 #include "engine/component.h"
6 #include "engine/system.h"
7 #include "engine/touchable.h"
8 #include "scripting/luabind.h"
9 #include "engine/typedefs.h"
10 
11 #include <luabind/object.hpp>
12 #include <memory>
13 #include <OgreCommon.h>
14 #include <OgreMath.h>
15 #include <OgreVector3.h>
16 #include <unordered_set>
17 
18 namespace thrive {
19 
20 using BoostCompoundMapIterator = boost::range_detail::select_second_mutable_range<std::unordered_map<std::string, CompoundId>>;
21 using BoostAbsorbedMapIterator = boost::range_detail::select_first_range<std::unordered_map<CompoundId, float>>;
22 
26 class CompoundRegistry final {
27 
28 public:
29 
46  static luabind::scope
47  luaBindings();
48 
55  static void
57  const std::string& filename
58  );
59 
63  static void
65  luabind::object configTable
66  );
67 
89  static CompoundId
91  const std::string& internalName,
92  const std::string& displayName,
93  const std::string& meshName,
94  double meshScale,
95  int unitVolume
96  );
97 
123  static CompoundId
125  const std::string& internalName,
126  const std::string& displayName,
127  const std::string& meshName,
128  double meshScale,
129  int unitVolume,
130  std::function<bool(EntityId, double)>* effect
131  );
132 
158  static CompoundId
160  const std::string& internalName,
161  const std::string& displayName,
162  const std::string& meshName,
163  double meshScale,
164  int unitVolume,
165  const luabind::object& effect
166  );
167 
177  static std::string
179  CompoundId id
180  );
181 
191  static std::string
193  CompoundId id
194  );
195 
205  static int
207  CompoundId id
208  );
209 
219  static CompoundId
221  const std::string& internalName
222  );
223 
230  static const BoostCompoundMapIterator
232  );
233 
244  static std::string
246  CompoundId compoundId
247  );
248 
259  static double
261  CompoundId compoundId
262  );
263 
272  static std::function<bool(EntityId, double)>*
274  CompoundId id
275  );
276 
287  static bool
288  isAgentType(
289  CompoundId id
290  );
291 
292  CompoundRegistry() = delete;
293 
294 };
295 
296 }
static CompoundId registerAgentType(const std::string &internalName, const std::string &displayName, const std::string &meshName, double meshScale, int unitVolume, std::function< bool(EntityId, double)> *effect)
Registers a new agent type.
Definition: compound_registry.cpp:256
static int getCompoundUnitVolume(CompoundId id)
Obtains the size of a compound.
Definition: compound_registry.cpp:303
static void loadFromXML(const std::string &filename)
Loads compounds from an XML document.
Definition: compound_registry.cpp:101
static void loadFromLua(luabind::object configTable)
loads compounds from a lua config table
Definition: compound_registry.cpp:80
static std::string getCompoundDisplayName(CompoundId id)
Obtains the display name of an compound.
Definition: compound_registry.cpp:285
static std::string getCompoundMeshName(CompoundId compoundId)
Obtains the name of the corresponding mesh.
Definition: compound_registry.cpp:328
static const BoostCompoundMapIterator getCompoundList()
Obtains the IDs of all currently registered compounds.
Definition: compound_registry.cpp:347
static std::function< bool(EntityId, double)> * getAgentEffect(CompoundId id)
Obtains the effect of the corresponding agent.
Definition: compound_registry.cpp:353
static luabind::scope luaBindings()
Lua bindings.
Definition: compound_registry.cpp:25
Definition: bullet_ogre_conversion.h:6
static CompoundId registerCompoundType(const std::string &internalName, const std::string &displayName, const std::string &meshName, double meshScale, int unitVolume)
Registers a new compound type.
Definition: compound_registry.cpp:213
Static class keeping track of compounds, their Id's, internal and displayed names.
Definition: compound_registry.h:26
static std::string getCompoundInternalName(CompoundId id)
Obtains the internal name of an compound.
Definition: compound_registry.cpp:294
static double getCompoundMeshScale(CompoundId compoundId)
Obtains the scale of the corresponding mesh.
Definition: compound_registry.cpp:337
static CompoundId getCompoundId(const std::string &internalName)
Obtains the Id of an internal name corresponding to a registered compound.
Definition: compound_registry.cpp:312
static bool isAgentType(CompoundId id)
Obtains the scale of the corresponding mesh.
Definition: compound_registry.cpp:363