HealthComponent Class
Component for tracking entity health and damage. More...
Declaration
Public Constructors Index
| HealthComponent ()=default | |
| HealthComponent (const float maxHealth) | |
|
Constructs a HealthComponent with the given maximum health. More... | |
| HealthComponent (const HealthComponent &other) | |
|
Copy constructor. More... | |
| HealthComponent (HealthComponent &&) noexcept=default | |
Public Operators Index
| HealthComponent & | operator= (const HealthComponent &)=default |
| HealthComponent & | operator= (HealthComponent &&) noexcept=default |
Public Member Functions Index
| bool | isEnabled () const noexcept |
|
Checks whether this component is enabled. More... | |
| void | enable () noexcept |
|
Enables this component. More... | |
| void | disable () noexcept |
|
Disables this component. More... | |
| void | setHealthDepletedBehavior (const HealthDepletedBehavior behavior) noexcept |
|
Sets the health depletion response behaviour. More... | |
| HealthDepletedBehavior | healthDepletedBehavior () const noexcept |
|
Returns the health depletion response behaviour. More... | |
| void | takeDamage (const float damage) noexcept |
|
Applies damage to this entity. More... | |
| void | heal (const float amount) noexcept |
|
Heals this entity. More... | |
| void | setMaxHealth (const float maxHealth) noexcept |
|
Sets the maximum health value. More... | |
| bool | isAlive () const noexcept |
|
Checks if the entity is alive. More... | |
| float | health () const noexcept |
|
Returns the current health value. More... | |
| float | maxHealth () const noexcept |
|
Returns the maximum health value. More... | |
| bool | isDirty () const noexcept |
|
Checks whether the health value has been modified. More... | |
| void | clearDirty () noexcept |
|
Resets the dirty flag. More... | |
| void | reset () |
|
Resets health to maximum. More... | |
| void | onAcquire () noexcept |
|
Called when this entity is acquired from a pool. More... | |
| void | onRelease () noexcept |
|
Called when this entity is released back to a pool. More... | |
Private Member Attributes Index
| float | maxHealth_ {} |
|
Maximum health value. More... | |
| float | health_ {} |
|
Current health value. More... | |
| bool | isEnabled_ = true |
|
Whether this component is enabled. More... | |
| HealthDepletedBehavior | healthDepletedBehavior_ = HealthDepletedBehavior::None |
|
Flags controlling the response when health reaches zero. More... | |
| bool | isDirty_ = true |
|
True if the health value was modified since the last clear. More... | |
Description
Component for tracking entity health and damage.
Manages current and maximum health values for an entity. Provides methods for taking damage, healing, and checking alive status.
Definition at line 26 of file HealthComponent.ixx.
Public Constructors
HealthComponent()
| default |
Definition at line 83 of file HealthComponent.ixx.
Referenced by HealthComponent, HealthComponent, operator= and operator=.
HealthComponent()
| inline explicit |
Constructs a HealthComponent with the given maximum health.
- Parameters
-
maxHealth The maximum health value.
Definition at line 90 of file HealthComponent.ixx.
Reference maxHealth.
HealthComponent()
| inline |
Copy constructor.
- Parameters
-
other The component to copy from.
Definition at line 97 of file HealthComponent.ixx.
Reference HealthComponent.
HealthComponent()
| noexcept default |
Definition at line 107 of file HealthComponent.ixx.
Reference HealthComponent.
Public Operators
operator=()
| default |
Definition at line 106 of file HealthComponent.ixx.
Reference HealthComponent.
operator=()
| noexcept default |
Definition at line 108 of file HealthComponent.ixx.
Reference HealthComponent.
Public Member Functions
clearDirty()
| inline noexcept |
Resets the dirty flag.
Definition at line 201 of file HealthComponent.ixx.
disable()
| inline noexcept |
Disables this component.
Definition at line 79 of file HealthComponent.ixx.
enable()
| inline noexcept |
Enables this component.
Definition at line 72 of file HealthComponent.ixx.
heal()
| inline noexcept |
Heals this entity.
Health is clamped to the maximum health value.
- Parameters
-
amount The amount to heal.
Definition at line 147 of file HealthComponent.ixx.
health()
| inline nodiscard noexcept |
Returns the current health value.
- Returns
The current health.
Definition at line 176 of file HealthComponent.ixx.
healthDepletedBehavior()
| inline nodiscard noexcept |
Returns the health depletion response behaviour.
- Returns
Current HealthDepletedBehavior flags.
Definition at line 124 of file HealthComponent.ixx.
isAlive()
| inline nodiscard noexcept |
Checks if the entity is alive.
- Returns
True if health is greater than 0.
Definition at line 167 of file HealthComponent.ixx.
Referenced by helios::engine::mechanics::health::HealthManager::flush.
isDirty()
| inline nodiscard noexcept |
Checks whether the health value has been modified.
- Returns
True if modified since the last clearDirty() call.
Definition at line 194 of file HealthComponent.ixx.
isEnabled()
| inline nodiscard noexcept |
Checks whether this component is enabled.
- Returns
True if enabled, false otherwise.
Definition at line 65 of file HealthComponent.ixx.
maxHealth()
| inline nodiscard noexcept |
Returns the maximum health value.
- Returns
The maximum health.
Definition at line 185 of file HealthComponent.ixx.
Referenced by HealthComponent and setMaxHealth.
onAcquire()
| inline noexcept |
onRelease()
| inline noexcept |
reset()
| inline |
setHealthDepletedBehavior()
| inline noexcept |
Sets the health depletion response behaviour.
- Parameters
-
behavior Bitmask of HealthDepletedBehavior flags.
Definition at line 115 of file HealthComponent.ixx.
Reference setHealthDepletedBehavior.
Referenced by setHealthDepletedBehavior.
setMaxHealth()
| inline noexcept |
Sets the maximum health value.
- Parameters
-
maxHealth The new maximum health.
Definition at line 157 of file HealthComponent.ixx.
Reference maxHealth.
takeDamage()
| inline noexcept |
Applies damage to this entity.
Health is clamped to a minimum of 0.
- Parameters
-
damage The amount of damage to apply.
Definition at line 135 of file HealthComponent.ixx.
Private Member Attributes
health_
|
healthDepletedBehavior_
|
Flags controlling the response when health reaches zero.
Definition at line 51 of file HealthComponent.ixx.
isDirty_
|
True if the health value was modified since the last clear.
Definition at line 56 of file HealthComponent.ixx.
isEnabled_
|
Whether this component is enabled.
Definition at line 44 of file HealthComponent.ixx.
maxHealth_
|
The documentation for this class was generated from the following file:
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.