R-Type
Distributed multiplayer game engine in C++
Loading...
Searching...
No Matches
ecs::HealthSystem Class Reference

System managing entity health, invincibility and death. More...

#include <HealthSystem.hpp>

Inheritance diagram for ecs::HealthSystem:
Inheritance graph
Collaboration diagram for ecs::HealthSystem:
Collaboration graph

Public Member Functions

 HealthSystem ()=default
 Default constructor.
 
 ~HealthSystem () override=default
 Default destructor.
 
void update (Registry &registry, float deltaTime) override
 Updates health-related logic for all entities.
 
ComponentMask getComponentMask () const override
 Gets the component mask for this system.
 
- Public Member Functions inherited from ecs::ISystem
virtual ~ISystem ()=default
 Virtual destructor.
 

Detailed Description

System managing entity health, invincibility and death.

Decrements invincibility timers, handles entity destruction when health reaches zero, and manages health-related game logic. Requires Health component.

Definition at line 23 of file HealthSystem.hpp.

Constructor & Destructor Documentation

◆ HealthSystem()

ecs::HealthSystem::HealthSystem ( )
default

Default constructor.

◆ ~HealthSystem()

ecs::HealthSystem::~HealthSystem ( )
overridedefault

Default destructor.

Member Function Documentation

◆ getComponentMask()

ComponentMask ecs::HealthSystem::getComponentMask ( ) const
overridevirtual

Gets the component mask for this system.

Returns
ComponentMask requiring Health component

Implements ecs::ISystem.

Definition at line 46 of file HealthSystem.cpp.

Referenced by update().

◆ update()

void ecs::HealthSystem::update ( Registry registry,
float  deltaTime 
)
overridevirtual

Updates health-related logic for all entities.

Updates health states and processes entity deaths.

Performs the following operations:

  • Decrements invincibility timers
  • Removes invincibility when timer expires
  • Destroys entities with zero or negative health
Parameters
registryReference to the ECS registry
deltaTimeTime elapsed since last frame (in seconds)

Implements ecs::ISystem.

Definition at line 16 of file HealthSystem.cpp.

References ecs::Registry::getComponent(), getComponentMask(), ecs::Registry::getEntitiesWithMask(), ecs::Health::getInvincibilityTimer(), ecs::Registry::hasComponent(), ecs::Killed, and ecs::Registry::setComponent().

Here is the call graph for this function:

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