Emergency 20 Dokumentation  4.2.0
em5::EntityHelper Class Reference

EMERGENCY 5 entity helper class. More...

#include <EntityHelper.h>

Inheritance diagram for em5::EntityHelper:
qsf::EntityHelper

Public Types

enum  CarryLoad { CARRY_PERSON = 1, PULL_PERSON = 2, PULL_OBJECT = 4, ANY = 7 }
 Types of load a unit can carry. This is a bitset (not because units can carry more than one but to check them together) More...
 

Public Member Functions

 EntityHelper (qsf::Entity &entity)
 Constructor. More...
 
 EntityHelper (const qsf::WeakPtr< qsf::Entity > &entity)
 
 EntityHelper (uint64 entityId, const qsf::Map &map)
 
 ~EntityHelper ()
 Destructor. More...
 
bool isInsideBox (const qsf::TransformComponent &boxTransform, bool yAxisCentered) const
 Is this entity inside the given box? More...
 
bool isInsideBox (const qsf::Entity &boxEntity) const
 
bool isInGangsterEventArea () const
 Is this entity inside the gangster event area? More...
 
bool isEntityDamaged () const
 Is entity damaged? More...
 
void makeImmovable () const
 
void setInvincible (bool invincible) const
 Turn on/off receiver for damage. Currently not work for buildings, complex fire, bushes/trees. More...
 
void applyPlacement (bool warpMovable=false) const
 Update the placement for the entity with it's current placement component. More...
 
void applyPlacementToPosition (glm::vec3 &position) const
 Applies entity basing placement to the given position. More...
 
void setPositionForMultiplay (glm::vec3 &position) const
 Warp the entity to the given position in a multiplay-compatible way. More...
 
template<typename T >
T * getGameLogic () const
 Return a game logic instance of a certain type. More...
 
qsf::GameLogicgetGameLogicByTypeId (uint32 gameLogicTypeId) const
 Return a game logic instance of a certain type. More...
 
bool destroyGameLogicByTypeId (uint32 gameLogicTypeId) const
 Destroy a game logic instance of a certain type. More...
 
bool isEntityValidEventTarget (FreeplayEvent *freeplayEvent=nullptr) const
 Is the entity a valid event target? More...
 
bool isEntityHidden () const
 Is the entity hidden? More...
 
bool isEntityVisibleOnScreen (bool includeShadow=true) const
 Is the entity visible on the local player's screen. More...
 
bool isEntityVisibleToCamera (qsf::CameraControlComponent &cameraControlComponent) const
 Is the entity inside a specific distance to the given camera. More...
 
bool isEntityVisibleForAnyPlayer () const
 Checks if the entity is inside a specific distance to the view position of any active player. More...
 
bool isInMapBoundaries () const
 
bool isInEventBoundaries () const
 
bool isCloseToMapBoundaries (float tolerance=1.0f) const
 
bool isCloseToEventBoundaries (float tolerance=1.0f) const
 
bool isEntityPerson () const
 "true" if this entity is a person of any kind More...
 
bool isEntityAnimal () const
 "true" if this entity is a animal More...
 
bool isCivilPerson () const
 "true" if this entity is a civil person More...
 
bool isGangsterPerson () const
 "true" if this entity is a gangster person More...
 
bool isGangsterCandidate (GangsterPool gangsterPoolType, bool mustBeInGangsterEventArea=true) const
 "true" if this entity can become a gangster More...
 
bool isValidGangsterEventTarget (qsf::Entity &gangsterEntity, bool needsToBeCivilTarget) const
 "true" if this entity can be attacked by the specified gangster. needsToBeCivilTarget can be set to exclude commandable units or gangsters as valid targets More...
 
bool isStunned () const
 "true" if this entity is stunned. Checks the BeStunnedAction More...
 
bool isCommandable () const
 "true" if this entity is a commandable squad object More...
 
bool isSquadPerson () const
 "true" if this entity is a commandable squad person More...
 
bool isPersonInjured () const
 Is this person injured? More...
 
bool isPersonContaminated () const
 Is this person contaminated? More...
 
bool isPersonWaving () const
 Is the person waving out of an window. More...
 
bool isPersonBuried () const
 Is the person buried. More...
 
bool isCarrying (CarryLoad type=ANY) const
 Check if a unit is carrying any of the given types. More...
 
uint64 getCarryTarget (CarryLoad type) const
 Get the entity ID of the carried object. You can check for types together as it's not possible to carry more than 1 object at a time. More...
 
void clearCarryTarget (CarryLoad type) const
 Reset the carry flag for the given type (or types) More...
 
bool isCarryingAnotherPerson () const
 "true" if the entity has logic for carrying an person More...
 
bool isGuidingPerson () const
 "true" if the entity has an action to guide another person (for example an arrested person) More...
 
bool isPullingPerson () const
 
bool isPullingObject () const
 
bool isCarriedByOtherPerson () const
 
bool isSquadPersonInValidState () const
 
bool isSquadVehicleInValidState () const
 
bool isSquadUnitInValidState () const
 
bool isCivilPersonInValidState () const
 
bool isUnitInValidState () const
 
bool isUnitInValidAndHealthyState () const
 
bool isBuildingInValidState () const
 
bool isArrested () const
 
bool canUseUmbrella () const
 
bool isRedirectingTraffic () const
 "true" if the person has the right editing and state for using umbrella at rain time. This function ignores if the umbrella is currently equipped or not. More...
 
void disconnectFromHydrant () const
 Use to disconnect firemen from hydrants. This functions removes all reservations and free the hydrant. No animations are playing. More...
 
bool canPlaySelectionFeedback () const
 The entity can play acoustic responds when it gets selected. More...
 
bool canPlayCommandFeedback () const
 The entity can play acoustic responds when it gets a command. More...
 
GangsterBaseLogicturnIntoGangsterByType (const qsf::StringHash &gangsterTypeId) const
 Turn entity into a gangster of specific type. More...
 
GangsterBaseLogicturnIntoGangster (const qsf::StringHash &gangsterLogicId, bool fleeInCar) const
 Turn entity into a gangster using a given gangster logic. More...
 
bool isGangsterFleeing () const
 Is the gangster fleeing from police. More...
 
bool isEntityBuilding () const
 Is this entity a building or not? More...
 
bool isEntityIndustrialPlant () const
 Is entity a industrial plant or not? More...
 
bool isBuildingDamaged () const
 Is building damaged? More...
 
bool isBuildingDestroyed () const
 Is building destroyed? More...
 
void placeEntityAtBuildingDoor (qsf::Entity &buildingEntity, bool lookToDoor=true) const
 
bool isVehicle () const
 "true if the entity is any kind of vehicle" More...
 
bool isHelicopter () const
 "true if the entity is a helicopter" More...
 
bool isBoat () const
 "true if the entity is a motorboat boat" More...
 
bool isShip () const
 "true if the entity is a FLB ship" More...
 
bool isFlying () const
 "true if the entity is flying (Starting the rotor is already considered flying) More...
 
bool isUnit (qsf::NamedIdentifier unitName) const
 "true if the entity is a unit with More...
 
bool isVehicleDestroyed () const
 
bool isRoadVehicle () const
 "true if the entity is a road vehicle of any kind" More...
 
bool isCivilRoadVehicle () const
 "true" if entity is a civil road vehicle More...
 
bool isSquadRoadVehicle () const
 "true" if entity is a road vehicle squad More...
 
bool isSquadVehicle () const
 "true" if entity is a vehicle squad More...
 
bool isRoadVehicleDamaged () const
 "true" if road vehicle is damaged More...
 
bool isGangsterRoadVehicle () const
 "true if the entity is a road vehicle with a gangster contained inside More...
 
bool checkVehicleHasFreeSeats (qsf::Entity &vehicleEntity) const
 "true" if target road vehicle has enough space for this entity More...
 
bool checkVehicleHasFreeSeatsForSquadPerson (qsf::Entity &vehicleEntity, OrderInfo &targetVehicleOrderInfo, const std::string &callerUnitName) const
 
bool checkVehicleHasFreeSeatsForPassengerPerson (qsf::Entity &vehicleEntity, OrderInfo &targetVehicleOrderInfo) const
 
int countVehicleFreeSeatsForSquadPerson (qsf::Entity &vehicleEntity, OrderInfo &targetVehicleOrderInfo, const std::string &callerUnitName) const
 
int countVehicleFreeSeatsForPassengerPerson (qsf::Entity &vehicleEntity, OrderInfo &targetVehicleOrderInfo) const
 
RoadVehicleComponentgetReachableRoadVehicleWithEquipment (const std::string &equipmentName) const
 Return a road vehicle that supports the given equipment type. Uses the nearest one found. More...
 
bool hasEquipment (const std::string &equipmentName) const
 Check if the entity has the given equipment in it's InventoryComponent. (typically used for checking if unit vehicles support a certain equipment) More...
 
bool isEntityVegetation () const
 Is entity part of the vegetation? More...
 
bool isEntityTree () const
 Is entity a tree. More...
 
bool isBurning () const
 Is entity burning? More...
 
bool isBurned () const
 Is this entity burned? More...
 
bool isBurnable () const
 Is this entity generally burnable (even if it was already fully burned or is burning right now)? More...
 
bool canBeSetOnFireNow () const
 Can this entity be set on fire right now, i.e. is it burnable, not fully burned yet and does not burn already? More...
 
bool startFire (FreeplayEvent *freeplayEvent=nullptr, bool fullFire=false) const
 Let this entity start to burn. More...
 
bool stopFire () const
 Let this entity stop burning. More...
 
void setCanBurn (bool canBurn) const
 Enable/Disable that this entity can burn. More...
 
bool isContainerEmpty () const
 Return "true" if the container of the entity is empty. More...
 
qsf::EntitygetContainerEntity () const
 Return the entity in which the owner is inside, or null pointer if there is none. More...
 
qsf::EntitygetContainerEntitySafe () const
 Return the container entity the entity is nested in. More...
 
bool isEntityInBuilding () const
 Return "true" if entity is inside building. More...
 
bool isEntityInVehicle () const
 Return "true" if entity is inside vehicle. More...
 
bool isEntityInRoadVehicle () const
 
qsf::game::PrototypeContainergetPrototypeContainer () const
 
bool isEntityHardLinked () const
 
void unlinkFromParent () const
 
void enterContainer (qsf::Entity &containerEntity, uint32 containerCategory=0, bool hidden=true) const
 The entity handled by the EntityHelper instance enters a container. More...
 
void leaveContainer (bool unhide=true) const
 
bool isInContainer (qsf::Entity &containerEntity, uint32 containerCategory) const
 
bool isInContainer (qsf::Entity &containerEntity) const
 
void setCollisionEnabled (bool collision) const
 
bool isEntityBuried () const
 
bool isFireReadyToCleanup () const
 Are the fire components ready to cleanup. More...
 
void cleanupFire () const
 Cleanup fire component. More...
 
bool checkEntityHasEventTag (const std::string &tag) const
 
bool checkForInitializedEventIdComponent (FreeplayEvent *freeplayEvent=nullptr) const
 Check if there is an initialized event ID component. More...
 
bool checkForEventIdComponent () const
 Check if there is an event ID component at all. More...
 
FreeplayEventgetFreeplayEvent () const
 Get the event of the event ID component of the entity. Can return null pointer. More...
 
uint32 getFreeplayEventId () const
 Get the event ID of the event that effects the entity. More...
 
qsf::EntitygetActiveEquipmentEntity () const
 
qsf::game::EquipmentComponentgetActiveEquipmentComponent () const
 
bool checkIsActiveEquipment (const std::string &equipmentName) const
 Return "true" if the active equipment has the given name (e.g.. "chainsaw") More...
 
void storeActiveEquipmentInInventory () const
 
void storeInventoryEquipmentAsActive () const
 
void deleteActiveEquipment (qsf::Time timeToDelete=qsf::Time::ZERO) const
 Call to destroy the currently active equipment (if any), also take takes care for correct handling in inventory and selection. More...
 
void linkEquipmentToEntity (qsf::Entity &parent) const
 
void showEquipment (const std::string &equipmentPrefab, int forceTintColorIndex=-1) const
 Call to create new equipment from prefab and make it visible (equipped) Does nothing if this is already the active equipment Does call deleteActiveEquipment() when another equipment is active. More...
 
void deleteAllLinkedChild ()
 Destroy all linked child entities. Also delete MeshAnimationTestComponent. Use-case are e.g. pre-edited gangster or gaper how changed back to normal behavior (e.g. ambient gangster with beer, know turning into real gangster with weapon) More...
 
void moveEntityInOwnerLayer (qsf::Entity &entityToMove) const
 
uint32 getUnitPlayerIndex () const
 
bool isUnitFromLocalPlayer () const
 Returns true if the entity is a unit and assigned to the local player. More...
 
bool isUnitOfDifferentPlayer () const
 Returns true if the entity is a unit and assigned to a another player (i.e. not the local player) More...
 
OrderInfogetOrderInfo () const
 Get the order info of the entity. Can return null pointer. More...
 
void unregisterFromUnitPool () const
 
void blockFromUnitPool () const
 
void unregisterOrBlockFromUnitPool (bool unregister) const
 Help to combine the redundant code between unregisterFromUnitPool() and blockFromUnitPool(), the boolean parameter indicates what branch is going. More...
 
qsf::EntitygetParentEntity () const
 Get the parent entity of the link component, returns nullptr if not linked. More...
 
void enableShineThroughEffect (bool enable=true) const
 Enable/Disable shine-through effect for the wrapped entity. More...
 
void setFlareActive (bool active) const
 Find a linked flare and change its activity. More...
 
void setLightActive (bool active) const
 Activates/Deactivates lights in the entity. More...
 
qsf::EntitygetClosestEntity (const std::vector< qsf::Entity * > &entities) const
 Finds the entity closest to this one Use case: You already picked those entity candidates, that fulfill certain requirements, now you need the one that is at nearest distance. More...
 
bool isFading () const
 Check if entity is fading in or out using the "em5::FadeEffectComponent". More...
 
void fadeIn (qsf::Time fadeTime=qsf::Time::fromSeconds(1.0f)) const
 Fade in an entity using the "em5::FadeEffectComponent". More...
 
void fadeOut (qsf::Time fadeTime=qsf::Time::fromSeconds(1.0f), bool deleteOwner=false) const
 Fade out an entity using the "em5::FadeEffectComponent"; the entity is not deleted, just hidden. More...
 
void setVisibleAndFade (bool visible, qsf::Time fadeTime=qsf::Time::fromSeconds(1.0f)) const
 Set entity visible or not and fade to that state. More...
 
void getComponentsFromChildrenById (uint32 componentId, std::vector< qsf::Component * > &output) const
 Return a vector of component instances of a certain type. More...
 
template<typename T >
void getComponentsFromChildren (std::vector< T * > &output) const
 Return a vector of component instances of a certain type. More...
 
bool hasEnabledMeshAnimationTestComponent () const
 Check whether or not the entity has an enabled mesh animation test component. More...
 
void disableMeshAnimationTestComponent ()
 Disable (but not destroy) mesh animation test component. More...
 
- Public Member Functions inherited from qsf::EntityHelper
 EntityHelper (Entity &entity)
 Constructor. More...
 
 ~EntityHelper ()
 Destructor. More...
 
EntitygetEntity () const
 Return the encapsulated entity. More...
 
std::string getName () const
 Return the name of an entity by using the metadata component. More...
 
LayergetLayer () const
 Return the layer the entity is registered to. More...
 
uint32 getLayerId () const
 Return the ID of the layer the entity is registered to. More...
 
const TransformgetTransform () const
 Return the world space transform of the entity. More...
 
const glm::vec3 & getPosition () const
 Return the world space position of the entity. More...
 
void setPosition (const glm::vec3 &position) const
 Set the world space position of the entity. More...
 
glm::vec3 vec3PositionWorldToLocal (const glm::vec3 &position) const
 Transform a given world space position into a local space position relative to a given world space transform. More...
 
glm::vec3 vec3PositionLocalToWorld (const glm::vec3 &position) const
 Transform a given local space position relative to a given world space transform into a world space position. More...
 
Line lineWorldToLocal (const Line &line) const
 Transform a given world space line into a local space line relative to a given world space transform. More...
 
Line lineLocalToWorld (const Line &line) const
 Transform a given local space line relative to a given world space transform into a world space line. More...
 
Ray rayWorldToLocal (const Ray &ray) const
 Transform a given world space ray into a local space ray relative to a given world space transform. More...
 
Ray rayLocalToWorld (const Ray &ray) const
 Transform a given local space ray relative to a given world space transform into a world space ray. More...
 
bool getSphere (glm::vec3 &center, float &radius) const
 Return a suited sphere enclosing the entity. More...
 
bool getAxisAlignedBoundingBox (glm::vec3 &minimumPoint, glm::vec3 &maximumPoint) const
 Return a suited axis aligned bounding box enclosing the entity. More...
 
bool getBoundingBoxExtents (glm::vec3 &extents) const
 Return the bounding box extents of the entity. More...
 

Static Public Member Functions

static void setupEntityAsGhost (qsf::Entity &entity, uint32 playerIndex)
 
static void setupEntityAsGhost (qsf::Entity &entity, const qsf::Entity &parentEntity)
 
static void teardownEntityAsGhost (qsf::Entity &entity)
 
static bool isPositionVisibleForAnyPlayer (const glm::vec3 &entityPosition, float additionalRadius=0.0f)
 

Additional Inherited Members

- Protected Attributes inherited from qsf::EntityHelper
EntitymEntity
 Entity to use, always valid, do not destroy the instance. More...
 

Detailed Description

EMERGENCY 5 entity helper class.

Member Enumeration Documentation

Types of load a unit can carry. This is a bitset (not because units can carry more than one but to check them together)

Enumerator
CARRY_PERSON 
PULL_PERSON 
PULL_OBJECT 
ANY 

Constructor & Destructor Documentation

em5::EntityHelper::EntityHelper ( qsf::Entity entity)
inlineexplicit

Constructor.

em5::EntityHelper::EntityHelper ( const qsf::WeakPtr< qsf::Entity > &  entity)
explicit
em5::EntityHelper::EntityHelper ( uint64  entityId,
const qsf::Map map 
)
em5::EntityHelper::~EntityHelper ( )
inline

Destructor.

Member Function Documentation

void em5::EntityHelper::applyPlacement ( bool  warpMovable = false) const

Update the placement for the entity with it's current placement component.

Parameters
[in]warpMovableWhen "true" the movableComponent will be warped to the new position (avoiding interpolation)
void em5::EntityHelper::applyPlacementToPosition ( glm::vec3 &  position) const

Applies entity basing placement to the given position.

Parameters
[in,out]positionPosition to apply placement to
void em5::EntityHelper::blockFromUnitPool ( ) const
bool em5::EntityHelper::canBeSetOnFireNow ( ) const

Can this entity be set on fire right now, i.e. is it burnable, not fully burned yet and does not burn already?

bool em5::EntityHelper::canPlayCommandFeedback ( ) const

The entity can play acoustic responds when it gets a command.

bool em5::EntityHelper::canPlaySelectionFeedback ( ) const

The entity can play acoustic responds when it gets selected.

bool em5::EntityHelper::canUseUmbrella ( ) const
bool em5::EntityHelper::checkEntityHasEventTag ( const std::string &  tag) const
bool em5::EntityHelper::checkForEventIdComponent ( ) const

Check if there is an event ID component at all.

bool em5::EntityHelper::checkForInitializedEventIdComponent ( FreeplayEvent freeplayEvent = nullptr) const

Check if there is an initialized event ID component.

bool em5::EntityHelper::checkIsActiveEquipment ( const std::string &  equipmentName) const

Return "true" if the active equipment has the given name (e.g.. "chainsaw")

bool em5::EntityHelper::checkVehicleHasFreeSeats ( qsf::Entity vehicleEntity) const

"true" if target road vehicle has enough space for this entity

Parameters
[in]vehicleEntityThe entity we want to enter
Note
Use this function for checking for seats
bool em5::EntityHelper::checkVehicleHasFreeSeatsForPassengerPerson ( qsf::Entity vehicleEntity,
OrderInfo targetVehicleOrderInfo 
) const
bool em5::EntityHelper::checkVehicleHasFreeSeatsForSquadPerson ( qsf::Entity vehicleEntity,
OrderInfo targetVehicleOrderInfo,
const std::string &  callerUnitName 
) const
void em5::EntityHelper::cleanupFire ( ) const

Cleanup fire component.

void em5::EntityHelper::clearCarryTarget ( CarryLoad  type) const

Reset the carry flag for the given type (or types)

int em5::EntityHelper::countVehicleFreeSeatsForPassengerPerson ( qsf::Entity vehicleEntity,
OrderInfo targetVehicleOrderInfo 
) const
int em5::EntityHelper::countVehicleFreeSeatsForSquadPerson ( qsf::Entity vehicleEntity,
OrderInfo targetVehicleOrderInfo,
const std::string &  callerUnitName 
) const
void em5::EntityHelper::deleteActiveEquipment ( qsf::Time  timeToDelete = qsf::Time::ZERO) const

Call to destroy the currently active equipment (if any), also take takes care for correct handling in inventory and selection.

void em5::EntityHelper::deleteAllLinkedChild ( )

Destroy all linked child entities. Also delete MeshAnimationTestComponent. Use-case are e.g. pre-edited gangster or gaper how changed back to normal behavior (e.g. ambient gangster with beer, know turning into real gangster with weapon)

bool em5::EntityHelper::destroyGameLogicByTypeId ( uint32  gameLogicTypeId) const

Destroy a game logic instance of a certain type.

Parameters
[in]gameLogicTypeIdType ID of the game logic
Returns
"true" if a game logic was actually destroyed, "false" if none was found
void em5::EntityHelper::disableMeshAnimationTestComponent ( )

Disable (but not destroy) mesh animation test component.

void em5::EntityHelper::disconnectFromHydrant ( ) const

Use to disconnect firemen from hydrants. This functions removes all reservations and free the hydrant. No animations are playing.

void em5::EntityHelper::enableShineThroughEffect ( bool  enable = true) const

Enable/Disable shine-through effect for the wrapped entity.

void em5::EntityHelper::enterContainer ( qsf::Entity containerEntity,
uint32  containerCategory = 0,
bool  hidden = true 
) const

The entity handled by the EntityHelper instance enters a container.

Parameters
[in]containerEntityThe container entity which should be entered
[in]containerCategoryThe container category inside the container
[in]hiddenShould the entity after entering the container be hidden?
void em5::EntityHelper::fadeIn ( qsf::Time  fadeTime = qsf::Time::fromSeconds(1.0f)) const

Fade in an entity using the "em5::FadeEffectComponent".

Parameters
[in]fadeTimeTime taken for fading (1 second as default)
void em5::EntityHelper::fadeOut ( qsf::Time  fadeTime = qsf::Time::fromSeconds(1.0f),
bool  deleteOwner = false 
) const

Fade out an entity using the "em5::FadeEffectComponent"; the entity is not deleted, just hidden.

Parameters
[in]fadeTimeTime taken for fading (1 second as default)
[in]deleteOwner"true" if owner is deleted from map after fading (false as default)
qsf::game::EquipmentComponent* em5::EntityHelper::getActiveEquipmentComponent ( ) const
qsf::Entity* em5::EntityHelper::getActiveEquipmentEntity ( ) const
uint64 em5::EntityHelper::getCarryTarget ( CarryLoad  type) const

Get the entity ID of the carried object. You can check for types together as it's not possible to carry more than 1 object at a time.

qsf::Entity* em5::EntityHelper::getClosestEntity ( const std::vector< qsf::Entity * > &  entities) const

Finds the entity closest to this one Use case: You already picked those entity candidates, that fulfill certain requirements, now you need the one that is at nearest distance.

This function can deal with null pointers in "entities".

Returns
The closest entity from the given vector
template<typename T >
void em5::EntityHelper::getComponentsFromChildren ( std::vector< T * > &  output) const

Return a vector of component instances of a certain type.

Parameters
[out]outputAn vector of the requested component instances, zero size vector if no components were found, do not destroy the component instances in the vector
void em5::EntityHelper::getComponentsFromChildrenById ( uint32  componentId,
std::vector< qsf::Component * > &  output 
) const

Return a vector of component instances of a certain type.

Parameters
[out]outputAn vector of the requested component instances, zero size vector if no components were found, do not destroy the component instances in the vector
qsf::Entity* em5::EntityHelper::getContainerEntity ( ) const

Return the entity in which the owner is inside, or null pointer if there is none.

qsf::Entity& em5::EntityHelper::getContainerEntitySafe ( ) const

Return the container entity the entity is nested in.

FreeplayEvent* em5::EntityHelper::getFreeplayEvent ( ) const

Get the event of the event ID component of the entity. Can return null pointer.

uint32 em5::EntityHelper::getFreeplayEventId ( ) const

Get the event ID of the event that effects the entity.

Returns
The event ID of the event ID component or uninitialized if there is none
template<typename T >
T * em5::EntityHelper::getGameLogic ( ) const

Return a game logic instance of a certain type.

Returns
requested The requested game logic instance or a null pointer if none exists in this entity; do no destroy the returned instance
qsf::GameLogic* em5::EntityHelper::getGameLogicByTypeId ( uint32  gameLogicTypeId) const

Return a game logic instance of a certain type.

Parameters
[in]gameLogicTypeIdType ID of the game logic
Returns
The requested game logic instance or a null pointer if none exists in this entity; do no destroy the returned instance
OrderInfo* em5::EntityHelper::getOrderInfo ( ) const

Get the order info of the entity. Can return null pointer.

qsf::Entity* em5::EntityHelper::getParentEntity ( ) const

Get the parent entity of the link component, returns nullptr if not linked.

qsf::game::PrototypeContainer* em5::EntityHelper::getPrototypeContainer ( ) const
RoadVehicleComponent* em5::EntityHelper::getReachableRoadVehicleWithEquipment ( const std::string &  equipmentName) const

Return a road vehicle that supports the given equipment type. Uses the nearest one found.

uint32 em5::EntityHelper::getUnitPlayerIndex ( ) const
bool em5::EntityHelper::hasEnabledMeshAnimationTestComponent ( ) const

Check whether or not the entity has an enabled mesh animation test component.

bool em5::EntityHelper::hasEquipment ( const std::string &  equipmentName) const

Check if the entity has the given equipment in it's InventoryComponent. (typically used for checking if unit vehicles support a certain equipment)

bool em5::EntityHelper::isArrested ( ) const
bool em5::EntityHelper::isBoat ( ) const

"true if the entity is a motorboat boat"

bool em5::EntityHelper::isBuildingDamaged ( ) const

Is building damaged?

bool em5::EntityHelper::isBuildingDestroyed ( ) const

Is building destroyed?

bool em5::EntityHelper::isBuildingInValidState ( ) const
bool em5::EntityHelper::isBurnable ( ) const

Is this entity generally burnable (even if it was already fully burned or is burning right now)?

bool em5::EntityHelper::isBurned ( ) const

Is this entity burned?

bool em5::EntityHelper::isBurning ( ) const

Is entity burning?

bool em5::EntityHelper::isCarriedByOtherPerson ( ) const
bool em5::EntityHelper::isCarrying ( CarryLoad  type = ANY) const

Check if a unit is carrying any of the given types.

bool em5::EntityHelper::isCarryingAnotherPerson ( ) const

"true" if the entity has logic for carrying an person

bool em5::EntityHelper::isCivilPerson ( ) const

"true" if this entity is a civil person

bool em5::EntityHelper::isCivilPersonInValidState ( ) const
bool em5::EntityHelper::isCivilRoadVehicle ( ) const

"true" if entity is a civil road vehicle

bool em5::EntityHelper::isCloseToEventBoundaries ( float  tolerance = 1.0f) const
bool em5::EntityHelper::isCloseToMapBoundaries ( float  tolerance = 1.0f) const
bool em5::EntityHelper::isCommandable ( ) const

"true" if this entity is a commandable squad object

bool em5::EntityHelper::isContainerEmpty ( ) const

Return "true" if the container of the entity is empty.

bool em5::EntityHelper::isEntityAnimal ( ) const

"true" if this entity is a animal

bool em5::EntityHelper::isEntityBuilding ( ) const

Is this entity a building or not?

bool em5::EntityHelper::isEntityBuried ( ) const
bool em5::EntityHelper::isEntityDamaged ( ) const

Is entity damaged?

bool em5::EntityHelper::isEntityHardLinked ( ) const
bool em5::EntityHelper::isEntityHidden ( ) const

Is the entity hidden?

bool em5::EntityHelper::isEntityInBuilding ( ) const

Return "true" if entity is inside building.

bool em5::EntityHelper::isEntityIndustrialPlant ( ) const

Is entity a industrial plant or not?

bool em5::EntityHelper::isEntityInRoadVehicle ( ) const
bool em5::EntityHelper::isEntityInVehicle ( ) const

Return "true" if entity is inside vehicle.

bool em5::EntityHelper::isEntityPerson ( ) const

"true" if this entity is a person of any kind

bool em5::EntityHelper::isEntityTree ( ) const

Is entity a tree.

bool em5::EntityHelper::isEntityValidEventTarget ( FreeplayEvent freeplayEvent = nullptr) const

Is the entity a valid event target?

Remarks
This includes the following checks:
  • Is the entity already affected by any event, or when a freeplay event is given: not affected by the given one?
  • Is the entity outside of the map boundaries?
  • Is the entity hidden?
bool em5::EntityHelper::isEntityVegetation ( ) const

Is entity part of the vegetation?

bool em5::EntityHelper::isEntityVisibleForAnyPlayer ( ) const

Checks if the entity is inside a specific distance to the view position of any active player.

bool em5::EntityHelper::isEntityVisibleOnScreen ( bool  includeShadow = true) const

Is the entity visible on the local player's screen.

bool em5::EntityHelper::isEntityVisibleToCamera ( qsf::CameraControlComponent cameraControlComponent) const

Is the entity inside a specific distance to the given camera.

bool em5::EntityHelper::isFading ( ) const

Check if entity is fading in or out using the "em5::FadeEffectComponent".

bool em5::EntityHelper::isFireReadyToCleanup ( ) const

Are the fire components ready to cleanup.

bool em5::EntityHelper::isFlying ( ) const

"true if the entity is flying (Starting the rotor is already considered flying)

bool em5::EntityHelper::isGangsterCandidate ( GangsterPool  gangsterPoolType,
bool  mustBeInGangsterEventArea = true 
) const

"true" if this entity can become a gangster

bool em5::EntityHelper::isGangsterFleeing ( ) const

Is the gangster fleeing from police.

bool em5::EntityHelper::isGangsterPerson ( ) const

"true" if this entity is a gangster person

bool em5::EntityHelper::isGangsterRoadVehicle ( ) const

"true if the entity is a road vehicle with a gangster contained inside

bool em5::EntityHelper::isGuidingPerson ( ) const

"true" if the entity has an action to guide another person (for example an arrested person)

bool em5::EntityHelper::isHelicopter ( ) const

"true if the entity is a helicopter"

bool em5::EntityHelper::isInContainer ( qsf::Entity containerEntity,
uint32  containerCategory 
) const
bool em5::EntityHelper::isInContainer ( qsf::Entity containerEntity) const
bool em5::EntityHelper::isInEventBoundaries ( ) const
bool em5::EntityHelper::isInGangsterEventArea ( ) const

Is this entity inside the gangster event area?

bool em5::EntityHelper::isInMapBoundaries ( ) const
bool em5::EntityHelper::isInsideBox ( const qsf::TransformComponent boxTransform,
bool  yAxisCentered 
) const

Is this entity inside the given box?

bool em5::EntityHelper::isInsideBox ( const qsf::Entity boxEntity) const
bool em5::EntityHelper::isPersonBuried ( ) const

Is the person buried.

bool em5::EntityHelper::isPersonContaminated ( ) const

Is this person contaminated?

bool em5::EntityHelper::isPersonInjured ( ) const

Is this person injured?

bool em5::EntityHelper::isPersonWaving ( ) const

Is the person waving out of an window.

static bool em5::EntityHelper::isPositionVisibleForAnyPlayer ( const glm::vec3 &  entityPosition,
float  additionalRadius = 0.0f 
)
static
bool em5::EntityHelper::isPullingObject ( ) const
bool em5::EntityHelper::isPullingPerson ( ) const
bool em5::EntityHelper::isRedirectingTraffic ( ) const

"true" if the person has the right editing and state for using umbrella at rain time. This function ignores if the umbrella is currently equipped or not.

bool em5::EntityHelper::isRoadVehicle ( ) const

"true if the entity is a road vehicle of any kind"

bool em5::EntityHelper::isRoadVehicleDamaged ( ) const

"true" if road vehicle is damaged

bool em5::EntityHelper::isShip ( ) const

"true if the entity is a FLB ship"

bool em5::EntityHelper::isSquadPerson ( ) const

"true" if this entity is a commandable squad person

bool em5::EntityHelper::isSquadPersonInValidState ( ) const
bool em5::EntityHelper::isSquadRoadVehicle ( ) const

"true" if entity is a road vehicle squad

bool em5::EntityHelper::isSquadUnitInValidState ( ) const
bool em5::EntityHelper::isSquadVehicle ( ) const

"true" if entity is a vehicle squad

bool em5::EntityHelper::isSquadVehicleInValidState ( ) const
bool em5::EntityHelper::isStunned ( ) const

"true" if this entity is stunned. Checks the BeStunnedAction

bool em5::EntityHelper::isUnit ( qsf::NamedIdentifier  unitName) const

"true if the entity is a unit with

bool em5::EntityHelper::isUnitFromLocalPlayer ( ) const

Returns true if the entity is a unit and assigned to the local player.

bool em5::EntityHelper::isUnitInValidAndHealthyState ( ) const
bool em5::EntityHelper::isUnitInValidState ( ) const
bool em5::EntityHelper::isUnitOfDifferentPlayer ( ) const

Returns true if the entity is a unit and assigned to a another player (i.e. not the local player)

bool em5::EntityHelper::isValidGangsterEventTarget ( qsf::Entity gangsterEntity,
bool  needsToBeCivilTarget 
) const

"true" if this entity can be attacked by the specified gangster. needsToBeCivilTarget can be set to exclude commandable units or gangsters as valid targets

bool em5::EntityHelper::isVehicle ( ) const

"true if the entity is any kind of vehicle"

bool em5::EntityHelper::isVehicleDestroyed ( ) const
void em5::EntityHelper::leaveContainer ( bool  unhide = true) const
void em5::EntityHelper::linkEquipmentToEntity ( qsf::Entity parent) const
void em5::EntityHelper::makeImmovable ( ) const
void em5::EntityHelper::moveEntityInOwnerLayer ( qsf::Entity entityToMove) const
void em5::EntityHelper::placeEntityAtBuildingDoor ( qsf::Entity buildingEntity,
bool  lookToDoor = true 
) const
void em5::EntityHelper::setCanBurn ( bool  canBurn) const

Enable/Disable that this entity can burn.

Parameters
[in]canBurn"true" when the entity can burn otherwise "false"
Note
This method activates/deactivates the fire component associated with the entity When deactivated the fire component is excluded from any updates
void em5::EntityHelper::setCollisionEnabled ( bool  collision) const
void em5::EntityHelper::setFlareActive ( bool  active) const

Find a linked flare and change its activity.

void em5::EntityHelper::setInvincible ( bool  invincible) const

Turn on/off receiver for damage. Currently not work for buildings, complex fire, bushes/trees.

void em5::EntityHelper::setLightActive ( bool  active) const

Activates/Deactivates lights in the entity.

Parameters
[in]active"true" if the light should be active, otherwise false
void em5::EntityHelper::setPositionForMultiplay ( glm::vec3 &  position) const

Warp the entity to the given position in a multiplay-compatible way.

Parameters
[in]positionPosition to warp the entity to
static void em5::EntityHelper::setupEntityAsGhost ( qsf::Entity entity,
uint32  playerIndex 
)
static
static void em5::EntityHelper::setupEntityAsGhost ( qsf::Entity entity,
const qsf::Entity parentEntity 
)
static
void em5::EntityHelper::setVisibleAndFade ( bool  visible,
qsf::Time  fadeTime = qsf::Time::fromSeconds(1.0f) 
) const

Set entity visible or not and fade to that state.

Parameters
[in]fadeTimeTime taken for fading (1 second as default)
void em5::EntityHelper::showEquipment ( const std::string &  equipmentPrefab,
int  forceTintColorIndex = -1 
) const

Call to create new equipment from prefab and make it visible (equipped) Does nothing if this is already the active equipment Does call deleteActiveEquipment() when another equipment is active.

Parameters
[in]equipmentPrefabThe path to the prefab, e.g. "em5/prefab/equipment/equipment_police_pistol". As shortcut the constants defined in the "EquipmentAssets.h" can used. In this case the prefab must be inside the folder "em5/prefab/equipment/" e.g. showEquipment(equipment::HANDCUFFS)
[in]forceTintColorIndex-1 means random tint color, everything else is used as tint color for the equipment (if possible)
bool em5::EntityHelper::startFire ( FreeplayEvent freeplayEvent = nullptr,
bool  fullFire = false 
) const

Let this entity start to burn.

Parameters
[in]freeplayEventOptional freeplay event that the burning objects will get counted for
[in]fullFireIf "true", fire energy gets set to 100% and for complex fires, all fire components get incinerated
Returns
"true" if the entity is set on fire, "false" otherwise
bool em5::EntityHelper::stopFire ( ) const

Let this entity stop burning.

Returns
"true" if the entity is set on fire, "false" otherwise
void em5::EntityHelper::storeActiveEquipmentInInventory ( ) const
void em5::EntityHelper::storeInventoryEquipmentAsActive ( ) const
static void em5::EntityHelper::teardownEntityAsGhost ( qsf::Entity entity)
static
GangsterBaseLogic& em5::EntityHelper::turnIntoGangster ( const qsf::StringHash gangsterLogicId,
bool  fleeInCar 
) const

Turn entity into a gangster using a given gangster logic.

Returns
The new gangster logic instance, or a null pointer in case of an error
Note
  • Deprecated: Use "turnIntoGangsterByType" instead
GangsterBaseLogic& em5::EntityHelper::turnIntoGangsterByType ( const qsf::StringHash gangsterTypeId) const

Turn entity into a gangster of specific type.

Returns
The new gangster logic instance, or a null pointer in case of an error
void em5::EntityHelper::unlinkFromParent ( ) const
void em5::EntityHelper::unregisterFromUnitPool ( ) const
void em5::EntityHelper::unregisterOrBlockFromUnitPool ( bool  unregister) const

Help to combine the redundant code between unregisterFromUnitPool() and blockFromUnitPool(), the boolean parameter indicates what branch is going.

Parameters
[in]unregister"true" if unit must unregister from unit pool, false if unit must blocking

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