Thrive
Static Public Member Functions | List of all members
thrive::CompoundRegistry Class Referencefinal

Static class keeping track of compounds, their Id's, internal and displayed names. More...

#include <compound_registry.h>

Static Public Member Functions

static luabind::scope luaBindings ()
 Lua bindings. More...
 
static void loadFromXML (const std::string &filename)
 Loads compounds from an XML document. More...
 
static void loadFromLua (luabind::object configTable)
 loads compounds from a lua config table
 
static CompoundId registerCompoundType (const std::string &internalName, const std::string &displayName, const std::string &meshName, double meshScale, int unitVolume)
 Registers a new compound type. More...
 
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. More...
 
static CompoundId registerAgentType (const std::string &internalName, const std::string &displayName, const std::string &meshName, double meshScale, int unitVolume, const luabind::object &effect)
 Registers a new agent type. More...
 
static std::string getCompoundDisplayName (CompoundId id)
 Obtains the display name of an compound. More...
 
static std::string getCompoundInternalName (CompoundId id)
 Obtains the internal name of an compound. More...
 
static int getCompoundUnitVolume (CompoundId id)
 Obtains the size of a compound. More...
 
static CompoundId getCompoundId (const std::string &internalName)
 Obtains the Id of an internal name corresponding to a registered compound. More...
 
static const BoostCompoundMapIterator getCompoundList ()
 Obtains the IDs of all currently registered compounds. More...
 
static std::string getCompoundMeshName (CompoundId compoundId)
 Obtains the name of the corresponding mesh. More...
 
static double getCompoundMeshScale (CompoundId compoundId)
 Obtains the scale of the corresponding mesh. More...
 
static std::function< bool(EntityId, double)> * getAgentEffect (CompoundId id)
 Obtains the effect of the corresponding agent. More...
 
static bool isAgentType (CompoundId id)
 Obtains the scale of the corresponding mesh. More...
 

Detailed Description

Static class keeping track of compounds, their Id's, internal and displayed names.

Member Function Documentation

std::function< bool(EntityId, double)> * CompoundRegistry::getAgentEffect ( CompoundId  id)
static

Obtains the effect of the corresponding agent.

Parameters
compoundIdThe id of the compound to acquire the effect of
Returns
A function pointer, to the agent effect function
std::string CompoundRegistry::getCompoundDisplayName ( CompoundId  id)
static

Obtains the display name of an compound.

Parameters
idId of the compound to obtain display name from
Returns
Compound name to display to users
CompoundId CompoundRegistry::getCompoundId ( const std::string &  internalName)
static

Obtains the Id of an internal name corresponding to a registered compound.

Parameters
internalNameThe internal name of the compound. Must not already exist in collection or invalid_argument is thrown.
Returns
CompoundId of the compound if it is registered. If compound is not registered an out_of_range exception is thrown.
std::string CompoundRegistry::getCompoundInternalName ( CompoundId  id)
static

Obtains the internal name of an compound.

Parameters
idId of the compound to obtain internal name from
Returns
Compound name for internal use
const BoostCompoundMapIterator CompoundRegistry::getCompoundList ( )
static

Obtains the IDs of all currently registered compounds.

Returns
Array of all registered compound IDs
std::string CompoundRegistry::getCompoundMeshName ( CompoundId  compoundId)
static

Obtains the name of the corresponding mesh.

Parameters
compoundIdThe id of the compound to acquire the mesh name from
Returns
A string containing the name of the compounds mesh. If compound is not registered an out_of_range exception is thrown.
double CompoundRegistry::getCompoundMeshScale ( CompoundId  compoundId)
static

Obtains the scale of the corresponding mesh.

Parameters
compoundIdThe id of the compound to acquire the mesh scale from
Returns
A double equal to the scale of the model If compound is not registered an out_of_range exception is thrown.
int CompoundRegistry::getCompoundUnitVolume ( CompoundId  id)
static

Obtains the size of a compound.

Parameters
idId of the compound to obtain size from
Returns
Compound size for internal use
bool CompoundRegistry::isAgentType ( CompoundId  id)
static

Obtains the scale of the corresponding mesh.

Parameters
compoundIdThe id of the compound to check if its an agent
Returns
True if compound is an agent, false otherwise If compound is not registered an out_of_range exception is thrown.
void CompoundRegistry::loadFromXML ( const std::string &  filename)
static

Loads compounds from an XML document.

Parameters
filenameThe document to load from
luabind::scope CompoundRegistry::luaBindings ( )
static
CompoundId CompoundRegistry::registerAgentType ( const std::string &  internalName,
const std::string &  displayName,
const std::string &  meshName,
double  meshScale,
int  unitVolume,
std::function< bool(EntityId, double)> *  effect 
)
static

Registers a new agent type.

Parameters
internalNameThe name to be used internally for reference across game instances
displayNameName to be displayed to users
meshNameName of the model to use for this compound
meshScaleThe relative size of the mesh
unitVolumeSize of the compound when stored and transported
effectA function pointer for the action to be performed on the absorbing entity. This function should take the id of the recieving entity as parameter and return true.
Returns
Id of new agent
CompoundId CompoundRegistry::registerAgentType ( const std::string &  internalName,
const std::string &  displayName,
const std::string &  meshName,
double  meshScale,
int  unitVolume,
const luabind::object &  effect 
)
static

Registers a new agent type.

Parameters
internalNameThe name to be used internally for reference across game instances
displayNameName to be displayed to users
meshNameName of the model to use for this agent
meshScaleThe relative size of the mesh
unitVolumeSize of the compound when stored and transported
effectA lua function for the action to be performed on the absorbing entity. This function should take the id of the recieving entity as parameter and return true.
Returns
Id of new agent
CompoundId CompoundRegistry::registerCompoundType ( const std::string &  internalName,
const std::string &  displayName,
const std::string &  meshName,
double  meshScale,
int  unitVolume 
)
static

Registers a new compound type.

Parameters
internalNameThe name to be used internally for reference across game instances
displayNameName to be displayed to users
meshNameName of the model to use for this compound
meshScaleThe relative size of the mesh
unitVolumeSize of the compound when stored and transported
Returns
Id of new compound

The documentation for this class was generated from the following files: