Emergency 2017 Dokumentation  v3.0.1
em5::MapHelper Class Reference

EMERGENCY 5 map helper class. More...

#include <MapHelper.h>

Public Member Functions

 MapHelper (qsf::Map &map)
 Constructor. More...
 
 ~MapHelper ()
 Destructor. More...
 
bool destroyEntityById (uint64 entityId)
 Destroy the entity by its given ID. More...
 
qsf::EntitycreateObjectByLocalPrefabAssetId (const qsf::StringHash &localAssetId, bool sendMessage=true) const
 Create an entity from the given prefab. More...
 
qsf::EntitycreateEntityByPrototypeReference (const qsf::Prototype &prototype, bool sendMessage=true) const
 Create an entity from the given Prototype. WARNING: copies only the entity, not the childs. More...
 
void showEntityParticleIds (const std::vector< uint64 > &particleEntityIds, bool show, bool repeatAnimation, bool showByHeight=false, float worldYOffset=0.0f, bool restart=false) const
 Entity particles are shown. More...
 
void disableEntityParticleIds (const std::vector< uint64 > &particleEntityIds) const
 Entity particles are disabled. More...
 
void hideParticleChildrenAtMapSave (std::vector< uint64 > &particleIds) const
 Hides all particle links. More...
 
qsf::ParticlesComponentspawnParticle (qsf::LocalAssetId prefabAssetId, float timeout, const glm::vec3 &position, const glm::vec3 &scale=glm::vec3(1.f, 1.f, 1.f), const glm::quat &rotation=glm::quat(), bool isMultiplayerRelevant=true)
 Create a fire and forget particle which destructs itself again after the given time. More...
 
void showEntityIds (std::vector< uint64 > &entityIds, bool show, bool showByHeight=false, float worldYOffset=0.0f) const
 
template<typename T >
void showComponentofEntityIds (std::vector< uint64 > &entityIds, bool show) const
 
bool isNightTime () const
 Return "true" is time of day between 8pm (20.00Uhr) and 7am (7:00Uhr) More...
 
qsf::EntitygetHeadQuarter () const
 Return the entity that represents the headquarter. More...
 
bool isContaminationArea (const glm::vec3 &position) const
 Return "true" if the position is inside an active contamination area. More...
 
std::pair< qsf::TransformComponent *, bool > getGangsterEventArea () const
 Returns the gangster event area, i.e. the area where gangster events shall happen. If it has not been specified with the map (i.e. no tag "GANGSTER_EVENT_AREA" exists) std::pair<nullptr, ...> is returned. The second argument of the returned pair depicts whether the box is centered at pivot. More...
 
qsf::EntitycreateObjectWithinGangsterEventAreaByLocalPrefabAssetId (const qsf::StringHash &localAssetId) const
 Creates the given prefab somewhere in the "gangster event area". 'Somewhere' means the entity is positioned at a random spawnpoint within that area. Returns nullptr if area does not exist or if there is no spawnpoint in that area. More...
 
qsf::EntitycreateGangsterFromPoolAndSpawnItInGangsterEventArea (GangsterPool gangsterPoolType) const
 Creates a gangster from the given pool somewhere in the "gangster event area". 'Somewhere' means the entity is positioned at a random spawnpoint within that area. Returns nullptr if area does not exist or if there is no spawnpoint in that area. More...
 
std::string getSpawnpoolNameFromGangsterPool (GangsterPool gangsterPoolType) const
 Maps the gangster pool enum to the spawnpool assets. More...
 
qsf::EntitygetOrCreateGangsterCandidateInGangsterEventArea (GangsterPool gangsterPoolType, const std::string &gangsterTag="") const
 Returns a gangster candidate from the given pool that is located in the gangster area. If such a gangster cannot be found, a new entity is created. Returns nullptr if area does not exist or if there is no spawnpoint in that area. More...
 
qsf::EntityreplaceCombinedEntityWithRealOne (qsf::Entity &combinedEntity) const
 Replaces a entity, which is a combined item (prefab name has _combined as postfix in name) with its "real" counterpart and returns the new instance If a replacing item could not be found the combined one is returned Note: The navigation and move to despawn components are deactivated on the real one. So anyone who needs the ai navigation active must set it up properly. More...
 
bool isInMapBoundaries (const glm::vec3 &position) const
 
bool isInEventBoundaries (const glm::vec3 &position) const
 
bool isEntityCloseToMapBoundaries (qsf::Entity &entity, float tolerance=1.0f)
 Returns whether the given entity is close to the map boundaries. More...
 
bool isEntityCloseToEventBoundaries (qsf::Entity &entity, float tolerance=1.0f)
 Returns whether the given entity is close to the event boundaries. More...
 
void prepareMapBorderLayer (const std::string &layerName)
 The entities outside the map boundaries don't need special game play stuff (in other words, its important to turn them off) More...
 
void unlockUpgradeComponent (const std::string &upgradeName)
 Search the map for entities with the upgrade name and unhide them. More...
 
void setEnergySectionEnabled (const qsf::StringHash &eventTag, bool enabled) const
 Enable/disable energy sections identified by meta-component tags. More...
 
void setEnergySectionEnabled (const std::vector< qsf::Entity * > &areaBoxes, bool enabled) const
 
void evacuateAllUnits (const qsf::StringHash &fromEventTag, const qsf::StringHash &toEventTag) const
 Evacuate all units (have "em5::CommandableComponent") from a given area to another given area. More...
 
void removeAllCiviliansInArea (const qsf::StringHash &areaEventTag)
 
void removeAllCivilPersonsInArea (const qsf::StringHash &areaEventTag)
 
void removeAllCivilVehiclesInArea (const qsf::StringHash &areaEventTag)
 
void removeCiviliansInArea (const qsf::StringHash &areaEventTag, bool ignorePersons, bool ignoreVehicles)
 
bool getPointOnClosestLane (const glm::vec3 &position, uint32 aiWorldIndex, uint32 laneTypeId, qsf::Transform &outTransform, boost::optional< glm::vec3 > wantedDirection=boost::optional< glm::vec3 >())
 
- Public Member Functions inherited from qsf::MapHelper
 MapHelper (Map &map)
 Constructor. More...
 
 ~MapHelper ()
 Destructor. More...
 
MapgetMap () const
 Return the map instance the map helper operates on. More...
 
std::string findUniqueNameForEntity (const std::string &name) const
 Search through all entities in the map and create an unique name, given by the input string. More...
 
void destroyNotSerializedPrototypeComponents (Prototype &prototype)
 Destroy all prototype component instances which should not be serialized (gizmo etc.) More...
 
bool activateLayerByName (const std::string &layerName, bool showError=true)
 Activate the given map layer. More...
 
bool deactivateLayerByName (const std::string &layerName, bool saveEntities=false, bool showError=true)
 Deactivate the given map layer. More...
 

Static Public Member Functions

static bool destroyEntity (qsf::Entity &entity)
 Destroy the given entity. More...
 
static void flyCameraToPosition (const glm::vec3 &position, Player &player, bool keepCurrentZoom)
 Fly the main camera to the position. More...
 
static void flyCameraToEntity (const qsf::Entity &focusEntity, Player &player, bool keepCurrentZoom)
 Fly the main camera to the entity. More...
 
static bool isUnitAutomatismActive ()
 "true" if the unit automatism flag is active More...
 
static bool isDamageSimulationActive ()
 "true" if the damage system flag is active More...
 
static void resetStoredGangsterEventAreaInformation ()
 Resets the stored information about the gangster event area. More...
 
static void resetNextEntityIdForMultiplay ()
 
static void activateLayer (qsf::Layer &layer, bool activate)
 

Additional Inherited Members

- Protected Attributes inherited from qsf::MapHelper
MapmMap
 Map to use, always valid, do not destroy the instance. More...
 

Detailed Description

EMERGENCY 5 map helper class.

Definition at line 57 of file MapHelper.h.

Constructor & Destructor Documentation

em5::MapHelper::MapHelper ( qsf::Map map)
inlineexplicit

Constructor.

Definition at line 21 of file MapHelper-inl.h.

em5::MapHelper::~MapHelper ( )
inline

Destructor.

Definition at line 27 of file MapHelper-inl.h.

Member Function Documentation

static void em5::MapHelper::activateLayer ( qsf::Layer layer,
bool  activate 
)
static
qsf::Entity* em5::MapHelper::createEntityByPrototypeReference ( const qsf::Prototype prototype,
bool  sendMessage = true 
) const

Create an entity from the given Prototype. WARNING: copies only the entity, not the childs.

Todo:
TODO(db): Make usable for multiplayer
qsf::Entity* em5::MapHelper::createGangsterFromPoolAndSpawnItInGangsterEventArea ( GangsterPool  gangsterPoolType) const

Creates a gangster from the given pool somewhere in the "gangster event area". 'Somewhere' means the entity is positioned at a random spawnpoint within that area. Returns nullptr if area does not exist or if there is no spawnpoint in that area.

qsf::Entity* em5::MapHelper::createObjectByLocalPrefabAssetId ( const qsf::StringHash localAssetId,
bool  sendMessage = true 
) const

Create an entity from the given prefab.

qsf::Entity* em5::MapHelper::createObjectWithinGangsterEventAreaByLocalPrefabAssetId ( const qsf::StringHash localAssetId) const

Creates the given prefab somewhere in the "gangster event area". 'Somewhere' means the entity is positioned at a random spawnpoint within that area. Returns nullptr if area does not exist or if there is no spawnpoint in that area.

static bool em5::MapHelper::destroyEntity ( qsf::Entity entity)
static

Destroy the given entity.

bool em5::MapHelper::destroyEntityById ( uint64  entityId)

Destroy the entity by its given ID.

void em5::MapHelper::disableEntityParticleIds ( const std::vector< uint64 > &  particleEntityIds) const

Entity particles are disabled.

Parameters
[in]particleEntityIdsList of entityIds for example from an entity slot
void em5::MapHelper::evacuateAllUnits ( const qsf::StringHash fromEventTag,
const qsf::StringHash toEventTag 
) const

Evacuate all units (have "em5::CommandableComponent") from a given area to another given area.

Remarks
Usage example: Place "Global asset ID 619601 - Local asset name "em5/prefab/debug/debug_box" - Local asset ID 3641566145" and use scale to define the area. Add an event tag component ("qsf::game::EventTagComponent") and define tags (e.g. "FromArea" or "ToArea") to make it possible for game-logic to address this defined area.
static void em5::MapHelper::flyCameraToEntity ( const qsf::Entity focusEntity,
Player player,
bool  keepCurrentZoom 
)
static

Fly the main camera to the entity.

static void em5::MapHelper::flyCameraToPosition ( const glm::vec3 &  position,
Player player,
bool  keepCurrentZoom 
)
static

Fly the main camera to the position.

std::pair<qsf::TransformComponent*, bool> em5::MapHelper::getGangsterEventArea ( ) const

Returns the gangster event area, i.e. the area where gangster events shall happen. If it has not been specified with the map (i.e. no tag "GANGSTER_EVENT_AREA" exists) std::pair<nullptr, ...> is returned. The second argument of the returned pair depicts whether the box is centered at pivot.

qsf::Entity* em5::MapHelper::getHeadQuarter ( ) const

Return the entity that represents the headquarter.

Note
qsf::Entity* em5::MapHelper::getOrCreateGangsterCandidateInGangsterEventArea ( GangsterPool  gangsterPoolType,
const std::string &  gangsterTag = "" 
) const

Returns a gangster candidate from the given pool that is located in the gangster area. If such a gangster cannot be found, a new entity is created. Returns nullptr if area does not exist or if there is no spawnpoint in that area.

bool em5::MapHelper::getPointOnClosestLane ( const glm::vec3 &  position,
uint32  aiWorldIndex,
uint32  laneTypeId,
qsf::Transform outTransform,
boost::optional< glm::vec3 >  wantedDirection = boost::optional< glm::vec3 >() 
)
std::string em5::MapHelper::getSpawnpoolNameFromGangsterPool ( GangsterPool  gangsterPoolType) const

Maps the gangster pool enum to the spawnpool assets.

void em5::MapHelper::hideParticleChildrenAtMapSave ( std::vector< uint64 > &  particleIds) const

Hides all particle links.

Note
  • Use this only in the special case of map saving
bool em5::MapHelper::isContaminationArea ( const glm::vec3 &  position) const

Return "true" if the position is inside an active contamination area.

Note
  • Careful, might be slow, so don't use constantly.
static bool em5::MapHelper::isDamageSimulationActive ( )
static

"true" if the damage system flag is active

bool em5::MapHelper::isEntityCloseToEventBoundaries ( qsf::Entity entity,
float  tolerance = 1.0f 
)

Returns whether the given entity is close to the event boundaries.

bool em5::MapHelper::isEntityCloseToMapBoundaries ( qsf::Entity entity,
float  tolerance = 1.0f 
)

Returns whether the given entity is close to the map boundaries.

bool em5::MapHelper::isInEventBoundaries ( const glm::vec3 &  position) const
bool em5::MapHelper::isInMapBoundaries ( const glm::vec3 &  position) const
bool em5::MapHelper::isNightTime ( ) const

Return "true" is time of day between 8pm (20.00Uhr) and 7am (7:00Uhr)

static bool em5::MapHelper::isUnitAutomatismActive ( )
static

"true" if the unit automatism flag is active

void em5::MapHelper::prepareMapBorderLayer ( const std::string &  layerName)

The entities outside the map boundaries don't need special game play stuff (in other words, its important to turn them off)

void em5::MapHelper::removeAllCiviliansInArea ( const qsf::StringHash areaEventTag)
void em5::MapHelper::removeAllCivilPersonsInArea ( const qsf::StringHash areaEventTag)
void em5::MapHelper::removeAllCivilVehiclesInArea ( const qsf::StringHash areaEventTag)
void em5::MapHelper::removeCiviliansInArea ( const qsf::StringHash areaEventTag,
bool  ignorePersons,
bool  ignoreVehicles 
)
qsf::Entity* em5::MapHelper::replaceCombinedEntityWithRealOne ( qsf::Entity combinedEntity) const

Replaces a entity, which is a combined item (prefab name has _combined as postfix in name) with its "real" counterpart and returns the new instance If a replacing item could not be found the combined one is returned Note: The navigation and move to despawn components are deactivated on the real one. So anyone who needs the ai navigation active must set it up properly.

static void em5::MapHelper::resetNextEntityIdForMultiplay ( )
static
static void em5::MapHelper::resetStoredGangsterEventAreaInformation ( )
static

Resets the stored information about the gangster event area.

void em5::MapHelper::setEnergySectionEnabled ( const qsf::StringHash eventTag,
bool  enabled 
) const

Enable/disable energy sections identified by meta-component tags.

Remarks
Usage example: Place "Global asset ID 619601 - Local asset name "em5/prefab/debug/debug_box" - Local asset ID 3641566145" and use scale to define the area. Add an event tag component ("qsf::game::EventTagComponent") and define tags (e.g. "EnergySection1" or "EnergySection2") to make it possible for game-logic to address this defined area.
Note
  • Activates/deactivates "em5::LightTimeControlComponent" instances inside the energy section
void em5::MapHelper::setEnergySectionEnabled ( const std::vector< qsf::Entity * > &  areaBoxes,
bool  enabled 
) const
template<typename T >
void em5::MapHelper::showComponentofEntityIds ( std::vector< uint64 > &  entityIds,
bool  show 
) const

Definition at line 33 of file MapHelper-inl.h.

void em5::MapHelper::showEntityIds ( std::vector< uint64 > &  entityIds,
bool  show,
bool  showByHeight = false,
float  worldYOffset = 0.0f 
) const
void em5::MapHelper::showEntityParticleIds ( const std::vector< uint64 > &  particleEntityIds,
bool  show,
bool  repeatAnimation,
bool  showByHeight = false,
float  worldYOffset = 0.0f,
bool  restart = false 
) const

Entity particles are shown.

Parameters
[in]particleEntityIdsList of entityIds for example from an entity slot
[in]showIf particle are shown or not / Is irrelevant if showByHeight is true
[in]repeatAnimationIf animations are repeated or not
[in]showByHeightHeight check with worldYOffset is used (for example for clipping)
[in]worldYOffsetUsed for height check
[in]restartUsed for restart if the particle effect is already finished
qsf::ParticlesComponent* em5::MapHelper::spawnParticle ( qsf::LocalAssetId  prefabAssetId,
float  timeout,
const glm::vec3 &  position,
const glm::vec3 &  scale = glm::vec3(1.f, 1.f, 1.f),
const glm::quat &  rotation = glm::quat(),
bool  isMultiplayerRelevant = true 
)

Create a fire and forget particle which destructs itself again after the given time.

void em5::MapHelper::unlockUpgradeComponent ( const std::string &  upgradeName)

Search the map for entities with the upgrade name and unhide them.


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