class
HealthComponent
- Module
- Game
- Header
#include "Gameplay/HealthComponent.h"- Namespace
Mowo
Properties
| Type | Name | Description |
|---|---|---|
std::function<void(float damage, MObject* instigator)> | onDamaged | |
std::function<void(MObject* instigator)> | onDeath | |
std::function<void(float amount)> | onHealed |
Public functions
| Returns | Name | Description |
|---|---|---|
void | SetMaxHealth | Set max health; fill also tops current health to the new max. |
void | SetHealth | clamps to [0, max]; clears/sets dead |
float | GetHealth | |
float | GetMaxHealth | |
float | GetHealthPercent | |
bool | IsDead | |
bool | IsFullHealth | |
void | SetInvulnerable | |
bool | IsInvulnerable | |
float | ApplyDamage | Apply damage; returns the amount actually dealt (0 if dead / invulnerable / non-positive). |
float | Heal | Heal up to max; returns the amount actually restored (0 if dead). |
void | Revive | back from dead at health (clamped > 0) |
void | Kill |
Function details
SetMaxHealth
C++
void SetMaxHealth(float v, bool fill = true)Set max health; fill also tops current health to the new max.
SetHealth
C++
void SetHealth(float v)clamps to [0, max]; clears/sets dead
GetHealth
C++
float GetHealth() constGetMaxHealth
C++
float GetMaxHealth() constGetHealthPercent
C++
float GetHealthPercent() constIsDead
C++
bool IsDead() constIsFullHealth
C++
bool IsFullHealth() constSetInvulnerable
C++
void SetInvulnerable(bool v)IsInvulnerable
C++
bool IsInvulnerable() constApplyDamage
C++
float ApplyDamage(float amount, MObject* instigator = nullptr)Apply damage; returns the amount actually dealt (0 if dead / invulnerable / non-positive). Fires onDamaged, and onDeath once if health reaches 0.
Heal
C++
float Heal(float amount)Heal up to max; returns the amount actually restored (0 if dead).
Revive
C++
void Revive(float health)back from dead at health (clamped > 0)
Kill
C++
void Kill(MObject* instigator = nullptr)Generated from Gameplay/HealthComponent.h via game.json · Nov 5, 2026Version 1.0.0