|
R-Type
Distributed multiplayer game engine in C++
|
Component representing entity health and invincibility. More...
#include <Health.hpp>


Public Member Functions | |
| Health (int maxHealth) | |
| Constructor with maximum health only. Sets current health equal to max health. | |
| Health (int currentHealth, int maxHealth) | |
| Constructor with current and maximum health. | |
| ~Health () override=default | |
| int | getCurrentHealth () const |
| Get current health points. | |
| int | getMaxHealth () const |
| Get maximum health points. | |
| bool | isInvincible () const |
| Check if entity is invincible. | |
| float | getInvincibilityTimer () const |
| Get remaining invincibility time. | |
| void | setMaxHealth (int health) |
| Set maximum health. | |
| void | setCurrentHealth (int health) |
| Set current health. | |
| void | setInvincible (bool invincible) |
| Set invincibility state. | |
| void | setInvincibilityTimer (float timer) |
| Set invincibility timer. | |
| bool | takeDamage (int amount) |
| Apply damage to the entity. Respects invincibility frames - no damage taken if invincible. | |
| void | heal (int amount) |
| Restore health points. Cannot exceed maximum health. | |
| bool | isDead () const |
| Check if entity is dead (health <= 0). | |
| ComponentType | getType () const override |
| Get the component type ID. | |
Public Member Functions inherited from ecs::IComponent | |
| virtual | ~IComponent ()=default |
| Virtual destructor. | |
Private Attributes | |
| int | _current |
| Current health points. | |
| int | _max |
| Maximum health points. | |
| bool | _invincible |
| Invincibility state. | |
| float | _timer |
| Invincibility duration timer in seconds. | |
Component representing entity health and invincibility.
Stores current and maximum health values, as well as temporary invincibility state. The invincibility timer is decremented by systems to manage temporary immunity.
Definition at line 20 of file Health.hpp.
|
inlineexplicit |
Constructor with maximum health only. Sets current health equal to max health.
| maxHealth | Maximum health points |
Definition at line 27 of file Health.hpp.
|
inline |
Constructor with current and maximum health.
| currentHealth | Starting health points |
| maxHealth | Maximum health points |
Definition at line 35 of file Health.hpp.
|
overridedefault |
|
inline |
Get current health points.
Definition at line 44 of file Health.hpp.
References _current.
Referenced by ecs::BuffSystem::_applyHealthRegen(), server::GameLogic::_checkGameOverCondition(), Server::_serializeEntity(), scripting::bindings::bindComponents(), ecs::CollisionSystem::handleModuleEnemyCollision(), ecs::CollisionSystem::handlePickup(), ecs::CollisionSystem::handleProjectileCollision(), and server::GameStateSerializer::serializeEntity().
|
inline |
Get remaining invincibility time.
Definition at line 62 of file Health.hpp.
References _timer.
Referenced by scripting::bindings::bindComponents(), and ecs::HealthSystem::update().
|
inline |
Get maximum health points.
Definition at line 50 of file Health.hpp.
References _max.
Referenced by ecs::BuffSystem::_applyHealthRegen(), scripting::bindings::bindComponents(), ecs::CollisionSystem::handlePickup(), ecs::CollisionSystem::handleProjectileCollision(), and server::GameStateSerializer::serializeEntity().
|
inlineoverridevirtual |
Get the component type ID.
Implements ecs::IComponent.
Definition at line 130 of file Health.hpp.
|
inline |
Restore health points. Cannot exceed maximum health.
| amount | Health to restore (positive value) |
Definition at line 110 of file Health.hpp.
|
inline |
Check if entity is dead (health <= 0).
Definition at line 124 of file Health.hpp.
References _current.
|
inline |
Check if entity is invincible.
Definition at line 56 of file Health.hpp.
References _invincible.
Referenced by scripting::bindings::bindComponents().
|
inline |
Set current health.
| health | New current health value |
Definition at line 74 of file Health.hpp.
References _current.
Referenced by ecs::BuffSystem::_applyHealthRegen(), scripting::bindings::bindComponents(), ecs::CollisionSystem::handleModuleEnemyCollision(), ecs::CollisionSystem::handlePickup(), and ecs::CollisionSystem::resolveWallCollision().
|
inline |
Set invincibility timer.
| timer | Timer value in seconds |
Definition at line 86 of file Health.hpp.
References _timer.
Referenced by ecs::BuffSystem::_applyShield(), and scripting::bindings::bindComponents().
|
inline |
Set invincibility state.
| invincible | True to enable invincibility |
Definition at line 80 of file Health.hpp.
References _invincible.
Referenced by ecs::BuffSystem::_applyShield(), and scripting::bindings::bindComponents().
|
inline |
Set maximum health.
| health | New maximum health value |
Definition at line 68 of file Health.hpp.
References _max.
Referenced by scripting::bindings::bindComponents(), and ecs::CollisionSystem::handlePickup().
|
inline |
Apply damage to the entity. Respects invincibility frames - no damage taken if invincible.
| amount | Damage amount (positive value) |
Definition at line 94 of file Health.hpp.
References _current, and _invincible.
Referenced by ecs::CollisionSystem::handleProjectileCollision().
|
private |
Current health points.
Definition at line 133 of file Health.hpp.
Referenced by getCurrentHealth(), heal(), isDead(), setCurrentHealth(), and takeDamage().
|
private |
Invincibility state.
Definition at line 135 of file Health.hpp.
Referenced by isInvincible(), setInvincible(), and takeDamage().
|
private |
Maximum health points.
Definition at line 134 of file Health.hpp.
Referenced by getMaxHealth(), heal(), and setMaxHealth().
|
private |
Invincibility duration timer in seconds.
Definition at line 136 of file Health.hpp.
Referenced by getInvincibilityTimer(), and setInvincibilityTimer().