|
Monad Engine da02fba2
> Undercity Codex_
|
#include <HealthComponent.h>
Inheritance diagram for mnd::HealthComponent:
Collaboration diagram for mnd::HealthComponent:Public Types | |
| using | DamageFn = std::function< void(const DamageInfo &)> |
| using | DeathFn = std::function< void(const DamageInfo &)> |
Public Member Functions | |
| void | Update (f32 deltaTime) override |
| void | LoadProperties (const nlohmann::json &json) override |
| void | ApplyDamage (const DamageInfo &info) |
| Apply damage. Routed through DamageSystem::Apply, do not call directly. | |
| int | GetMax () const |
| int | GetCurrent () const |
| bool | IsDead () const |
| bool | IsInvulnerable () const |
| void | SetMax (int hp) |
| void | SetCurrent (int hp) |
| void | SetInvulnerable (bool inv) |
| void | SetDestroyOnDeath (bool b) |
| void | Heal (int amount) |
| Heal up to max. No-op if dead (use Revive for that). | |
| void | Revive () |
| Reset to full HP and clear dead state. | |
| void | OnDamage (DamageFn fn) |
| Subscribe to damage events. Listeners fire on every non-zero damage tick. | |
| void | OnDeath (DeathFn fn) |
| Subscribe to death event. Fires once per transition from alive→dead. | |
| void | SetShowBar (bool show) |
| Toggle on-screen 2D bar. | |
| bool | ShowsBar () const |
| virtual void | Init () |
| virtual size_t | GetTypeId () const =0 |
| GameObject * | GetOwner () |
Static Public Member Functions | |
| template<typename T > | |
| static size_t | StaticTypeId () |
Protected Attributes | |
| GameObject * | m_owner = nullptr |
Definition at line 30 of file HealthComponent.h.
| using mnd::HealthComponent::DamageFn = std::function<void(const DamageInfo &)> |
Definition at line 34 of file HealthComponent.h.
| using mnd::HealthComponent::DeathFn = std::function<void(const DamageInfo &)> |
Definition at line 35 of file HealthComponent.h.
| void mnd::HealthComponent::ApplyDamage | ( | const DamageInfo & | info | ) |
Apply damage. Routed through DamageSystem::Apply, do not call directly.
Definition at line 212 of file HealthComponent.cpp.
References mnd::DamageInfo::amount, IsDead(), mnd::Component::m_owner, and mnd::GameObject::MarkForDestroy().
|
inline |
Definition at line 44 of file HealthComponent.h.
|
inline |
Definition at line 43 of file HealthComponent.h.
|
inherited |
Definition at line 12 of file Component.cpp.
References mnd::Component::m_owner.
Referenced by mnd::MeshComponent::Update(), and mnd::SkinnedMeshComponent::Update().
|
pure virtualinherited |
| void mnd::HealthComponent::Heal | ( | int | amount | ) |
Heal up to max. No-op if dead (use Revive for that).
Definition at line 198 of file HealthComponent.cpp.
References IsDead().
|
virtualinherited |
Reimplemented in mnd::PhysicsComponent, and mnd::PlayerControllerComponent.
Definition at line 10 of file Component.cpp.
Referenced by mnd::GameObject::AddComponent().
|
inline |
Definition at line 45 of file HealthComponent.h.
Referenced by ApplyDamage(), and Heal().
|
inline |
Definition at line 46 of file HealthComponent.h.
|
overridevirtual |
Reimplemented from mnd::Component.
Definition at line 162 of file HealthComponent.cpp.
|
inline |
Subscribe to damage events. Listeners fire on every non-zero damage tick.
Definition at line 60 of file HealthComponent.h.
|
inline |
Subscribe to death event. Fires once per transition from alive→dead.
Definition at line 62 of file HealthComponent.h.
| void mnd::HealthComponent::Revive | ( | ) |
Reset to full HP and clear dead state.
Definition at line 207 of file HealthComponent.cpp.
| void mnd::HealthComponent::SetCurrent | ( | int | hp | ) |
Definition at line 193 of file HealthComponent.cpp.
|
inline |
Definition at line 51 of file HealthComponent.h.
|
inline |
Definition at line 50 of file HealthComponent.h.
| void mnd::HealthComponent::SetMax | ( | int | hp | ) |
Definition at line 187 of file HealthComponent.cpp.
|
inline |
Toggle on-screen 2D bar.
Definition at line 65 of file HealthComponent.h.
|
inline |
Definition at line 66 of file HealthComponent.h.
|
inlinestaticinherited |
Definition at line 50 of file Component.h.
|
overridevirtual |
Implements mnd::Component.
Definition at line 28 of file HealthComponent.cpp.
|
protectedinherited |
Definition at line 57 of file Component.h.
Referenced by mnd::GameObject::AddComponent(), ApplyDamage(), mnd::Component::GetOwner(), mnd::CameraComponent::GetViewMatrix(), mnd::PhysicsComponent::Init(), mnd::PlayerControllerComponent::Init(), mnd::PlayerControllerComponent::Update(), mnd::AudioComponent::Update(), mnd::AudioListenerComponent::Update(), and mnd::PhysicsComponent::Update().