Emergency 20 Dokumentation  4.2.0
em5::HealthComponent Class Reference

EMERGENCY 5 health component class. More...

#include <HealthComponent.h>

Inheritance diagram for em5::HealthComponent:
qsf::game::HealthComponent qsf::Component qsf::InheritedObject qsf::WeakPtrTarget qsf::Object

Public Types

enum  State { STATE_HEALTHY, STATE_INJURED, STATE_DEATHFIGHT, STATE_DEAD }
 
enum  ImmunityType {
  IMMUNITY_INJURY, IMMUNITY_ILLNESS, IMMUNITY_CONTAMINATION_RADIOACTIVE, IMMUNITY_CONTAMINATION_CHEMICAL,
  IMMUNITY_CONTAMINATION_PLAGUE, IMMUNITY_CONTAMINATION_BIOLOGICAL
}
 
typedef qsf::EnumBitmask< uint8, ImmunityTypeImmunityBitmask
 
typedef Injury::InjuryFlags InjuryFlags
 
typedef Injury::InjuryBitmask InjuryBitmask
 
typedef Injury::ContaminationType ContaminationType
 
- Public Types inherited from qsf::Component
enum  TransformChangeFlag {
  TRANSFORM_CHANGE_POSITION = 0x01, TRANSFORM_CHANGE_ROTATION = 0x02, TRANSFORM_CHANGE_SCALE = 0x04, TRANSFORM_CHANGE_TRANSFORM = 0x07,
  TRANSFORM_CHANGE_FOR_SIMULATION = 0x08, TRANSFORM_CHANGE_FOR_ANIMATION = 0x10
}
 
typedef BitFlagSet< uint8, TransformChangeFlagTransformChangeFlags
 
- 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 }
 

Public Member Functions

 HealthComponent (qsf::Prototype *prototype)
 Constructor. More...
 
virtual ~HealthComponent ()
 Destructor. More...
 
bool injurePersonByEventById (uint32 injuryId, FreeplayEvent *freeplayEvent, bool playCollapseAnimation=true)
 
void killPerson (FreeplayEvent *freeplayEvent, const VisualVitalSigns *visualVitalSigns=nullptr, const qsf::StringHash &InjuryId=injury::DUMMY_INJURY)
 
bool isReceivingFireDamage () const
 
void receiveDamage (float amount, damagetype::DamageType damageType, qsf::Component *sender)
 
float getHealthEnergy () const
 
void setHealthEnergy (float healthEnergy)
 
float getMaximumHealthEnergy () const
 
void setMaximumHealthEnergy (float MaximumHealthEnergy)
 
float getLifeEnergy () const
 
void setLifeEnergy (float lifeEnergy)
 
float getMaximumLifeEnergy () const
 
void setMaximumLifeEnergy (float maximumLifeEnergy)
 
float getDeathEnergy () const
 
void setDeathEnergy (float deathEnergy)
 
float getMaximumDeathEnergy () const
 
void setMaximumDeathEnergy (float maximumDeathEnergy)
 
State getState () const
 
bool isHealthy () const
 
bool isInjured () const
 
bool isDead () const
 
bool isMovable () const
 
Injury::InjuryBitmask getInjuryBitmask () const
 
VisualVitalSignsgetVisualVitalSigns ()
 
bool getIsDrowning () const
 Return if the person is drowning. More...
 
bool getIsKneeing () const
 Return if the person is kneeing due injury. More...
 
void setDrowningFollowUpInjury ()
 
const qsf::TimegetElapsedTimeAfterLastHeatEnergyReceived () const
 
const InjurygetInjury () const
 
uint32 getInjuryId () const
 
bool applyInjury (const Injury &injury, FreeplayEvent *freeplayEvent, bool playCollapseAnimation=true)
 
bool applyInjuryById (const qsf::StringHash &id, FreeplayEvent *freeplayEvent, bool playCollapseAnimation=true)
 
void healAllInjuries ()
 
void doctorTreatmentFinished ()
 
void updateInjuredIcon (bool forceUpdate=false)
 
bool getCanDoContaminationQuickTest () const
 
void setCanDoContaminationQuickTest (bool canDoContaminationQuickTest)
 
bool isInvincible () const
 
void setInvincible (bool invincible)
 
const ImmunityBitmaskgetImmunities () const
 
bool isImmune (ImmunityType immunityType) const
 
bool isImmune (const Injury &injury) const
 
void setImmunityType (ImmunityType immunityType, bool value=true)
 
std::string getImmunitiesAsString () const
 
void setImmunitiesByString (const std::string &immunities)
 
std::string getResistancesAsString () const
 
void setResistancesByString (const std::string &resistances)
 
float * getResistancesArray ()
 
bool isRegenerationDisabled () const
 
void setRegenerationDisabled (bool noRegeneration)
 
bool isTreatmentActive () const
 
bool isDiagnosisActive () const
 
bool isDiagnosisComplete () const
 
uint32 getDiagnosisId () const
 
void setTreatmentActive (bool treatment)
 
void setDiagnosisActive (bool diagnosis)
 
void setMedicalCareActive (bool care)
 
void setReanimationActive (bool reanimantion)
 
void setDiagnosisComplete (bool examined)
 
void setInjuredHealed ()
 
bool isContaminated () const
 
ContaminationType getContaminationType () const
 
void contaminate (ContaminationType contaminationType)
 
void decontaminate ()
 
bool isReadyForCleanup () const
 Check whether this component is ready for cleanup. More...
 
void cleanup ()
 Perform the cleanup. More...
 
std::string getFormattedDebugText () const
 
virtual void serialize (qsf::BinarySerializer &serializer) override
 Serialize or deserialize the component using a binary serializer. More...
 
- Public Member Functions inherited from qsf::game::HealthComponent
 HealthComponent (Prototype *prototype)
 Constructor. More...
 
- Public Member Functions inherited from qsf::Component
virtual ~Component ()
 Destructor. More...
 
PrototypegetPrototype () const
 Return the prototype this component is in. More...
 
EntitygetEntity () const
 Return a reference to the entity this component is in. More...
 
uint32 getId () const
 Return the unique component identifier. More...
 
ComponentManagergetComponentManager () const
 Return the component manager that's responsible for this component instance. More...
 
ComponentCollectiongetComponentCollection () const
 Return the component collection that's responsible for this component instance. More...
 
bool isSimulating () const
 Return whether or not the component is in simulating mode. More...
 
bool isActive () const
 Return whether or not the component is considered to be active. More...
 
void setActive (bool active)
 Set whether or not the component is considered to be active. More...
 
bool isDebug () const
 Return whether or not the component is considered to be in debug mode. More...
 
bool isHidden () const
 Return whether or not the component is hidden. More...
 
void setHidden (bool hidden)
 Set whether or not the component is hidden. More...
 
bool isGloballyHidden () const
 Return whether or not the component is globally hidden. More...
 
void setGloballyHidden (bool globallyHidden)
 Set whether or not the component is globally hidden. More...
 
bool isReallyHidden () const
 Return whether or not the component is really hidden. More...
 
bool startup (bool ownerIsRunning)
 Startup the component. More...
 
bool isRunning () const
 Return whether or not the component is up-and-running. More...
 
void shutdown ()
 Shutdown the component. More...
 
uint64 getPrototypeId () const
 Return the ID of the prototype this component is in. More...
 
uint64 getEntityId () const
 Return the ID of the entity this component is in. More...
 
virtual void onInvalidation ()
 Invalidate the component. More...
 
virtual void setDebug (bool debugMode)
 Set whether or not the component is considered to be in debug mode. More...
 
- Public Member Functions inherited from qsf::InheritedObject
void copyPropertyOverrideStateFrom (const InheritedObject &object, bool add=false)
 
void setAllPropertyOverrideFlags (bool value)
 
void autoCreatePropertyOverrideState ()
 
virtual camp::Value getPropertyDefaultValue (const StringHash &propertyId) const override
 
virtual PropertyOverrideState getPropertyOverrideState (const StringHash &propertyId) const override
 
virtual bool setPropertyOverrideState (const StringHash &propertyId, PropertyOverrideState overrideState) override
 
- 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 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...
 

Static Public Attributes

static const uint32 COMPONENT_ID
 "em5::HealthComponent" unique component ID More...
 
static const uint32 HEALTH_ENERGY
 Current health energy. More...
 
static const uint32 MAX_HEALTH_ENERGY
 Maximum health energy. More...
 
static const uint32 LIFE_ENERGY
 Current life energy. More...
 
static const uint32 MAX_LIFE_ENERGY
 Maximum life energy. More...
 
static const uint32 DEATH_ENERGY
 Current death energy. More...
 
static const uint32 MAX_DEATH_ENERGY
 Maximum death energy. More...
 
- Static Public Attributes inherited from qsf::game::HealthComponent
static const uint32 COMPONENT_ID
 "qsf::game::HealthComponent" unique component ID More...
 
- Static Public Attributes inherited from qsf::Component
static const uint32 COMPONENT_ID
 "qsf::Component" unique component ID More...
 

Protected Member Functions

virtual bool onStartup () override
 Startup the component. More...
 
virtual void onShutdown () override
 Shutdown the component. More...
 
virtual void onSetSimulating (bool simulating) override
 Set whether or not the component is in simulating mode. More...
 
- Protected Member Functions inherited from qsf::Component
 Component (Prototype *prototype)
 Constructor. More...
 
void promotePropertyChange (uint32 propertyId)
 A component property value was changed. More...
 
template<typename T , typename S >
bool assignAndPromoteChange (T &variable, const S &newValue, uint32 propertyId)
 Comfort function for updating an exported member variable and promoting any change that happened. More...
 
void setRegisterForSimulationTransformChanges (bool enable)
 Register or unregister this component as simulation transform listener. More...
 
void setRegisterForAnimationTransformChanges (bool enable)
 Register or unregister this component as animation transform listener. More...
 
virtual const ObjectgetPropertyDefaultsProvider () const override
 
virtual bool ignoreOwnerRunningState () const
 Return whether or not the component will only startup if the owner is in running state. More...
 
virtual bool implementsOnComponentPropertyChange () const
 Signal whether this component needs the "onComponentPropertyChange" callback at all. More...
 
virtual void onComponentPropertyChange (const Component &component, uint32 propertyId)
 Called in case a component property value was changed. More...
 
virtual void onComponentTransformChange (const Transform &transform, TransformChangeFlags flags)
 Called in case a component transformation value was changed. More...
 
virtual void onSetActive (bool active)
 Set whether or not the component is considered to be active. More...
 
virtual void onSetDebug (bool debug)
 Set whether or not the component is considered to be in debug mode. More...
 
virtual void onSetHidden (bool hidden)
 Set whether or not the component is considered to be hidden. More...
 
- Protected Member Functions inherited from qsf::InheritedObject
 InheritedObject ()
 Default constructor. More...
 
- Protected Member Functions inherited from qsf::Object
 Object ()
 Default constructor. More...
 
- Protected Member Functions inherited from qsf::WeakPtrTarget
 WeakPtrTarget ()
 Default constructor. More...
 
 WeakPtrTarget (const WeakPtrTarget &other)
 Copy constructor. More...
 
 WeakPtrTarget (WeakPtrTarget &&)=delete
 Delete the move constructor, as WeakPtrTarget would need a proper move constructor-implementation that ensures that its pointer gets updated in the WeakPtrBase as well. More...
 
 ~WeakPtrTarget ()
 Destructor. More...
 
void invalidateAllWeakPtr ()
 Invalidate all weak pointers to this object. More...
 
void operator= (const WeakPtrTarget &other)
 Copy operator. More...
 

Friends

class multiplayer::HealthData
 

Additional Inherited Members

- Protected Attributes inherited from qsf::InheritedObject
std::bitset< 128 > mPropertyOverrideFlags
 One bit for each property; if set, the property is overridden. More...
 

Detailed Description

EMERGENCY 5 health component class.

Note
  • Overview over the types of energies: -> Health energy: The energy when the person is not injured -> Life energy: The energy when the person is injured -> Death energy: The energy when the person is injured and had lost all life energy

Member Typedef Documentation

Member Enumeration Documentation

Immunity type

Enumerator
IMMUNITY_INJURY 
IMMUNITY_ILLNESS 
IMMUNITY_CONTAMINATION_RADIOACTIVE 
IMMUNITY_CONTAMINATION_CHEMICAL 
IMMUNITY_CONTAMINATION_PLAGUE 
IMMUNITY_CONTAMINATION_BIOLOGICAL 

Health state

Enumerator
STATE_HEALTHY 

Person is not injured.

STATE_INJURED 

Person is injured, possibly already treated.

STATE_DEATHFIGHT 

Person is near death, but can still be reanimated.

STATE_DEAD 

Person is dead.

Constructor & Destructor Documentation

em5::HealthComponent::HealthComponent ( qsf::Prototype prototype)
inlineexplicit

Constructor.

Parameters
[in]prototypeThe prototype this component is in, no null pointer allowed
em5::HealthComponent::~HealthComponent ( )
inlinevirtual

Destructor.

Reimplemented from qsf::game::HealthComponent.

Member Function Documentation

bool em5::HealthComponent::applyInjury ( const Injury injury,
FreeplayEvent freeplayEvent,
bool  playCollapseAnimation = true 
)
bool em5::HealthComponent::applyInjuryById ( const qsf::StringHash id,
FreeplayEvent freeplayEvent,
bool  playCollapseAnimation = true 
)
void em5::HealthComponent::cleanup ( )

Perform the cleanup.

void em5::HealthComponent::contaminate ( ContaminationType  contaminationType)
void em5::HealthComponent::decontaminate ( )
void em5::HealthComponent::doctorTreatmentFinished ( )
bool em5::HealthComponent::getCanDoContaminationQuickTest ( ) const
inline
Injury::ContaminationType em5::HealthComponent::getContaminationType ( ) const
inline
float em5::HealthComponent::getDeathEnergy ( ) const
inline
uint32 em5::HealthComponent::getDiagnosisId ( ) const
inline
const qsf::Time& em5::HealthComponent::getElapsedTimeAfterLastHeatEnergyReceived ( ) const
std::string em5::HealthComponent::getFormattedDebugText ( ) const
float em5::HealthComponent::getHealthEnergy ( ) const
inline
const HealthComponent::ImmunityBitmask & em5::HealthComponent::getImmunities ( ) const
inline
std::string em5::HealthComponent::getImmunitiesAsString ( ) const
const Injury * em5::HealthComponent::getInjury ( ) const
inline
Injury::InjuryBitmask em5::HealthComponent::getInjuryBitmask ( ) const
inline
uint32 em5::HealthComponent::getInjuryId ( ) const
inline
bool em5::HealthComponent::getIsDrowning ( ) const
inline

Return if the person is drowning.

bool em5::HealthComponent::getIsKneeing ( ) const
inline

Return if the person is kneeing due injury.

float em5::HealthComponent::getLifeEnergy ( ) const
inline
float em5::HealthComponent::getMaximumDeathEnergy ( ) const
inline
float em5::HealthComponent::getMaximumHealthEnergy ( ) const
inline
float em5::HealthComponent::getMaximumLifeEnergy ( ) const
inline
float* em5::HealthComponent::getResistancesArray ( )
std::string em5::HealthComponent::getResistancesAsString ( ) const
HealthComponent::State em5::HealthComponent::getState ( ) const
inline
VisualVitalSigns & em5::HealthComponent::getVisualVitalSigns ( )
inline
void em5::HealthComponent::healAllInjuries ( )
bool em5::HealthComponent::injurePersonByEventById ( uint32  injuryId,
FreeplayEvent freeplayEvent,
bool  playCollapseAnimation = true 
)

brief Use this method to injure a person by an event

bool em5::HealthComponent::isContaminated ( ) const
inline
bool em5::HealthComponent::isDead ( ) const
inline
bool em5::HealthComponent::isDiagnosisActive ( ) const
inline
bool em5::HealthComponent::isDiagnosisComplete ( ) const
inline
bool em5::HealthComponent::isHealthy ( ) const
inline
bool em5::HealthComponent::isImmune ( ImmunityType  immunityType) const
bool em5::HealthComponent::isImmune ( const Injury injury) const
bool em5::HealthComponent::isInjured ( ) const
inline
bool em5::HealthComponent::isInvincible ( ) const
inline
bool em5::HealthComponent::isMovable ( ) const
inline
bool em5::HealthComponent::isReadyForCleanup ( ) const
inline

Check whether this component is ready for cleanup.

bool em5::HealthComponent::isReceivingFireDamage ( ) const
bool em5::HealthComponent::isRegenerationDisabled ( ) const
bool em5::HealthComponent::isTreatmentActive ( ) const
inline
void em5::HealthComponent::killPerson ( FreeplayEvent freeplayEvent,
const VisualVitalSigns visualVitalSigns = nullptr,
const qsf::StringHash InjuryId = injury::DUMMY_INJURY 
)
virtual void em5::HealthComponent::onSetSimulating ( bool  simulating)
overrideprotectedvirtual

Set whether or not the component is in simulating mode.

Parameters
[in]active"true" if the component is in simulating mode, else "false"
Note
  • The default implementation is empty
  • This method is only called in case there's a real state change
  • In contrast to internal flags (e.g. Active, Debug), the simulating mode state can only be changed globally for a whole map
  • On component shutdown and simulating enabled, "onSetSimulating()" is automatically called with "false" before calling "onShutdown()"

Reimplemented from qsf::Component.

virtual void em5::HealthComponent::onShutdown ( )
overrideprotectedvirtual

Shutdown the component.

Note
  • Only called in case "onStartup()" returned successfully
  • The default implementation is empty

Reimplemented from qsf::Component.

virtual bool em5::HealthComponent::onStartup ( )
overrideprotectedvirtual

Startup the component.

Returns
"true" if all went fine, else "false"
Note
  • The default implementation is empty
  • Only components which are part of entities (concrete prototype instances) get started
  • When this method gets called, the properties might still be on default values but it's also possible that properties already have customized values. Take this into account when implementing your method.

Reimplemented from qsf::Component.

void em5::HealthComponent::receiveDamage ( float  amount,
damagetype::DamageType  damageType,
qsf::Component sender 
)
virtual void em5::HealthComponent::serialize ( qsf::BinarySerializer serializer)
overridevirtual

Serialize or deserialize the component using a binary serializer.

Parameters
[in]serializerThe serializer, which can be either in read or write mode

Reimplemented from qsf::Component.

void em5::HealthComponent::setCanDoContaminationQuickTest ( bool  canDoContaminationQuickTest)
inline
void em5::HealthComponent::setDeathEnergy ( float  deathEnergy)
void em5::HealthComponent::setDiagnosisActive ( bool  diagnosis)
inline
void em5::HealthComponent::setDiagnosisComplete ( bool  examined)
void em5::HealthComponent::setDrowningFollowUpInjury ( )
void em5::HealthComponent::setHealthEnergy ( float  healthEnergy)
void em5::HealthComponent::setImmunitiesByString ( const std::string &  immunities)
void em5::HealthComponent::setImmunityType ( ImmunityType  immunityType,
bool  value = true 
)
void em5::HealthComponent::setInjuredHealed ( )
inline
void em5::HealthComponent::setInvincible ( bool  invincible)
inline
void em5::HealthComponent::setLifeEnergy ( float  lifeEnergy)
void em5::HealthComponent::setMaximumDeathEnergy ( float  maximumDeathEnergy)
void em5::HealthComponent::setMaximumHealthEnergy ( float  MaximumHealthEnergy)
void em5::HealthComponent::setMaximumLifeEnergy ( float  maximumLifeEnergy)
void em5::HealthComponent::setMedicalCareActive ( bool  care)
inline
void em5::HealthComponent::setReanimationActive ( bool  reanimantion)
inline
void em5::HealthComponent::setRegenerationDisabled ( bool  noRegeneration)
void em5::HealthComponent::setResistancesByString ( const std::string &  resistances)
void em5::HealthComponent::setTreatmentActive ( bool  treatment)
inline
void em5::HealthComponent::updateInjuredIcon ( bool  forceUpdate = false)

Friends And Related Function Documentation

friend class multiplayer::HealthData
friend

Member Data Documentation

const uint32 em5::HealthComponent::COMPONENT_ID
static

"em5::HealthComponent" unique component ID

const uint32 em5::HealthComponent::DEATH_ENERGY
static

Current death energy.

const uint32 em5::HealthComponent::HEALTH_ENERGY
static

Current health energy.

const uint32 em5::HealthComponent::LIFE_ENERGY
static

Current life energy.

const uint32 em5::HealthComponent::MAX_DEATH_ENERGY
static

Maximum death energy.

const uint32 em5::HealthComponent::MAX_HEALTH_ENERGY
static

Maximum health energy.

const uint32 em5::HealthComponent::MAX_LIFE_ENERGY
static

Maximum life energy.


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