Emergency 20 Dokumentation  4.2.0
em5::UnitPool Class Reference

Keeps track of ordered units from the player and manages the ordering process for new units Spawning units has to register as spawning. Then they are blocked for other processes. An vehicle can only spawn personnel if the personnel is available. In case the unit died, we block the person. The resetting process takes place at every ingame day. More...

#include <UnitPool.h>

Inheritance diagram for em5::UnitPool:
qsf::Object

Public Member Functions

 UnitPool ()
 Default constructor. More...
 
virtual ~UnitPool ()
 Destructor. More...
 
void setGameEdition (VersionSwitch::Edition gameEdition)
 
void loadStartConfiguration ()
 
void eraseAllRegisteredUnitsFromPool ()
 
bool hasUnit (const qsf::StringHash &identifier) const
 
void registerUnitInSpawn (const OrderInfo &orderInfo, int amount=1)
 
void unregisterUnitInSpawn (const OrderInfo &orderInfo, int amount=1)
 
void registerUnitInMap (const OrderInfo &orderInfo, uint64 unitEntityId)
 
void unregisterUnitInMap (const OrderInfo &orderInfo, uint64 unitEntityId)
 
void registerUnitBlocking (const OrderInfo &orderInfo, int amount=1)
 
void unregisterAllUnitBlocking ()
 
uint32 getNumberMaxAvailable (const OrderInfo &orderInfo) const
 
uint32 getNumberMaxAvailableByName (const qsf::StringHash &identifier) const
 
bool isUnitAvailableInSpawn (const OrderInfo &orderInfo) const
 
uint32 getNumberInSpawning (const OrderInfo &orderInfo) const
 
uint32 getNumberBlocked (const OrderInfo &orderInfo) const
 
uint32 getNumberBlockedByName (const qsf::StringHash &identifier) const
 
bool isUnitAvailableInHQ (const OrderInfo &orderInfo) const
 
int getNumberInHQ (const OrderInfo &orderInfo) const
 
uint32 getNumberUnitsInUse (const OrderInfo &orderInfo) const
 
uint32 getNumberUnitsInUseByName (const qsf::StringHash &identifier) const
 
void getAllUnitsInUse (std::vector< uint64 > &allUnitsInUse) const
 
const std::vector< uint64 > & getUnitsInUse (const OrderInfo &orderinfo) const
 
const std::vector< uint64 > & getUnitsInUseByName (const qsf::StringHash &identifier) const
 
void increaseNumberAvailable (const std::string &unitName, int amount)
 
void increaseLimitForBuying (const std::string &unitName, int amount)
 
bool isBuyLimitReached (const OrderInfo &orderInfo) const
 
bool isBuyLimitReached (const std::string &unitName) const
 
void getAllUnitOrderInfos (std::vector< const OrderInfo * > &outOrderInfos) const
 
void getUnitOrderInfosByDepartment (units::Department, std::vector< const OrderInfo * > &outOrderInfos) const
 
int getOriginalOrderIndexOfOrderInfoId (uint32 orderInfoId) const
 
void replaceParamedicInUse (uint64 newSingleParamedicId, uint64 oldParamedicTeamId)
 Extra function for handling paramedic team. Replaced the stored paramedic ID with the new one. More...
 
void addAvailableUnitByName (const qsf::NamedIdentifier &unitName, uint32 unitCount, bool allowDuplicates)
 Function for adding units to the unit pool. Is used internally. Prefer using the unitpool asset instead of adding units manually. More...
 
void loadFromDefinition (const UnitPoolDefinition &unitPoolDefinition)
 Load a unit pool from a definition structure – only numbers of available units. More...
 
void serialize (qsf::BinarySerializer &serializer)
 Binary serialization of a unit pool – complete serialization. More...
 
void addDebugOutput (qsf::DebugDrawProxy &debugDrawProxy)
 Create debug output. More...
 
- Public Member Functions inherited from qsf::Object
virtual ~Object ()
 Destructor. More...
 
const camp::Class & getCampClass () const
 Return the CAMP class. More...
 
int getPropertyIndexById (const StringHash &propertyId) const
 Return the CAMP property index by using the unique class property ID. More...
 
uint32 getPropertyIdByIndex (int index) const
 Return the unique class property ID with the given index. More...
 
std::string getPropertyNameById (const StringHash &propertyId) const
 Return the CAMP property name by using the unique class property ID. More...
 
const camp::Property * getCampPropertyById (const StringHash &propertyId) const
 Return the CAMP property by using the unique class property ID. More...
 
void setPropertyValuesByString (const std::string &values)
 Set CAMP reflection property values by using a given string. More...
 
void setPropertiesToDefaultValues ()
 Set all CAMP reflection system properties to their default values. More...
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void serializeToBoostPTree (boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
bool deserializeFromBoostPTree (const boost::property_tree::ptree &pTree, const camp::Class &campClass, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL)
 
void serializeToBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL) const
 
void deserializeFromBinarySerializer (BinarySerializer &serializer, SerializationMode mode=MODE_MINIMAL, SerializationMethod serializationMethod=SERIALIZE_DIFFERENTIAL, bool setOverrideState=true)
 
virtual camp::Value getPropertyDefaultValue (const StringHash &propertyId) const
 
virtual PropertyOverrideState getPropertyOverrideState (const StringHash &propertyId) const
 
virtual bool setPropertyOverrideState (const StringHash &propertyId, PropertyOverrideState overrideState)
 
virtual void onPreDeserialize ()
 Called right before the object is deserialized using any of the above methods. Default implementation is empty. More...
 
virtual void onPostDeserialize ()
 Called right after the object was deserialized using any of the above methods. Default implementation is empty. More...
 
virtual ScriptgetAssociatedScript () const
 Return the script instance associated with this object instance. More...
 

Additional Inherited Members

- Public Types inherited from qsf::Object
enum  PropertyOverrideState { PROPERTY_INVALID, PROPERTY_DEFAULT, PROPERTY_OVERRIDE, PROPERTY_REMOVED }
 
enum  SerializationMethod { SERIALIZE_FLAT, SERIALIZE_COMPLETE, SERIALIZE_DIFFERENTIAL, SERIALIZE_IGNORE_UNKNOWN }
 
enum  SerializationMode { MODE_MINIMAL, MODE_COMPATIBLE }
 
- Protected Member Functions inherited from qsf::Object
 Object ()
 Default constructor. More...
 

Detailed Description

Keeps track of ordered units from the player and manages the ordering process for new units Spawning units has to register as spawning. Then they are blocked for other processes. An vehicle can only spawn personnel if the personnel is available. In case the unit died, we block the person. The resetting process takes place at every ingame day.

Constructor & Destructor Documentation

em5::UnitPool::UnitPool ( )

Default constructor.

virtual em5::UnitPool::~UnitPool ( )
virtual

Destructor.

Member Function Documentation

void em5::UnitPool::addAvailableUnitByName ( const qsf::NamedIdentifier unitName,
uint32  unitCount,
bool  allowDuplicates 
)

Function for adding units to the unit pool. Is used internally. Prefer using the unitpool asset instead of adding units manually.

void em5::UnitPool::addDebugOutput ( qsf::DebugDrawProxy debugDrawProxy)

Create debug output.

void em5::UnitPool::eraseAllRegisteredUnitsFromPool ( )
void em5::UnitPool::getAllUnitOrderInfos ( std::vector< const OrderInfo * > &  outOrderInfos) const
void em5::UnitPool::getAllUnitsInUse ( std::vector< uint64 > &  allUnitsInUse) const
uint32 em5::UnitPool::getNumberBlocked ( const OrderInfo orderInfo) const
uint32 em5::UnitPool::getNumberBlockedByName ( const qsf::StringHash identifier) const
int em5::UnitPool::getNumberInHQ ( const OrderInfo orderInfo) const
uint32 em5::UnitPool::getNumberInSpawning ( const OrderInfo orderInfo) const
uint32 em5::UnitPool::getNumberMaxAvailable ( const OrderInfo orderInfo) const
uint32 em5::UnitPool::getNumberMaxAvailableByName ( const qsf::StringHash identifier) const
uint32 em5::UnitPool::getNumberUnitsInUse ( const OrderInfo orderInfo) const
uint32 em5::UnitPool::getNumberUnitsInUseByName ( const qsf::StringHash identifier) const
int em5::UnitPool::getOriginalOrderIndexOfOrderInfoId ( uint32  orderInfoId) const
void em5::UnitPool::getUnitOrderInfosByDepartment ( units::Department  ,
std::vector< const OrderInfo * > &  outOrderInfos 
) const
const std::vector<uint64>& em5::UnitPool::getUnitsInUse ( const OrderInfo orderinfo) const
const std::vector<uint64>& em5::UnitPool::getUnitsInUseByName ( const qsf::StringHash identifier) const
bool em5::UnitPool::hasUnit ( const qsf::StringHash identifier) const
void em5::UnitPool::increaseLimitForBuying ( const std::string &  unitName,
int  amount 
)
void em5::UnitPool::increaseNumberAvailable ( const std::string &  unitName,
int  amount 
)
bool em5::UnitPool::isBuyLimitReached ( const OrderInfo orderInfo) const
bool em5::UnitPool::isBuyLimitReached ( const std::string &  unitName) const
bool em5::UnitPool::isUnitAvailableInHQ ( const OrderInfo orderInfo) const
bool em5::UnitPool::isUnitAvailableInSpawn ( const OrderInfo orderInfo) const
void em5::UnitPool::loadFromDefinition ( const UnitPoolDefinition unitPoolDefinition)

Load a unit pool from a definition structure – only numbers of available units.

void em5::UnitPool::loadStartConfiguration ( )
void em5::UnitPool::registerUnitBlocking ( const OrderInfo orderInfo,
int  amount = 1 
)
void em5::UnitPool::registerUnitInMap ( const OrderInfo orderInfo,
uint64  unitEntityId 
)
void em5::UnitPool::registerUnitInSpawn ( const OrderInfo orderInfo,
int  amount = 1 
)
void em5::UnitPool::replaceParamedicInUse ( uint64  newSingleParamedicId,
uint64  oldParamedicTeamId 
)

Extra function for handling paramedic team. Replaced the stored paramedic ID with the new one.

Note
It's important to call this function before the event spread helper acts with the old data (the playerHelper will not find the correct number of injured paramedics)
void em5::UnitPool::serialize ( qsf::BinarySerializer serializer)

Binary serialization of a unit pool – complete serialization.

void em5::UnitPool::setGameEdition ( VersionSwitch::Edition  gameEdition)
void em5::UnitPool::unregisterAllUnitBlocking ( )
void em5::UnitPool::unregisterUnitInMap ( const OrderInfo orderInfo,
uint64  unitEntityId 
)
void em5::UnitPool::unregisterUnitInSpawn ( const OrderInfo orderInfo,
int  amount = 1 
)

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