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

System managing buff timers and applying buff effects. More...

#include <BuffSystem.hpp>

Inheritance diagram for ecs::BuffSystem:
Inheritance graph
Collaboration diagram for ecs::BuffSystem:
Collaboration graph

Public Member Functions

 BuffSystem ()=default
 Constructs a BuffSystem.
 
 ~BuffSystem () override=default
 Destructor.
 
void update (Registry &registry, float deltaTime) override
 Update buff timers and apply effects.
 
ComponentMask getComponentMask () const override
 Gets the component mask for this system.
 
- Public Member Functions inherited from ecs::ISystem
virtual ~ISystem ()=default
 Virtual destructor.
 

Private Member Functions

void _updateBuffTimers (Buff &buff, float deltaTime)
 Update buff timers and remove expired ones.
 
void _applyBuffEffects (Address address, Registry &registry, const Buff &buff)
 Apply buff effects to entity stats.
 
void _applySpeedBoost (Velocity &velocity, float multiplier)
 Apply speed buff multiplier.
 
void _applyDamageBoost (Weapon &weapon, float multiplier)
 Apply damage buff multiplier.
 
void _applyFireRateBoost (Weapon &weapon, float multiplier)
 Apply fire rate buff multiplier.
 
void _applyShield (Health &health, float duration)
 Apply shield (invincibility)
 
void _applyHealthRegen (Health &health, float deltaTime, float regenRate)
 Apply health regeneration.
 

Detailed Description

System managing buff timers and applying buff effects.

Updates buff durations, applies stat modifications, and removes expired buffs. Handles both temporary and permanent buffs with different behaviors.

Definition at line 26 of file BuffSystem.hpp.

Constructor & Destructor Documentation

◆ BuffSystem()

ecs::BuffSystem::BuffSystem ( )
default

Constructs a BuffSystem.

◆ ~BuffSystem()

ecs::BuffSystem::~BuffSystem ( )
overridedefault

Destructor.

Member Function Documentation

◆ _applyBuffEffects()

void ecs::BuffSystem::_applyBuffEffects ( Address  address,
Registry registry,
const Buff buff 
)
private

Apply buff effects to entity stats.

Parameters
addressEntity address
registryRegistry reference
buffBuff component with active buffs

Definition at line 87 of file BuffSystem.cpp.

References ecs::Buff::getBuffs(), ecs::Registry::getComponent(), and ecs::Registry::hasComponent().

Referenced by update().

Here is the call graph for this function:

◆ _applyDamageBoost()

void ecs::BuffSystem::_applyDamageBoost ( Weapon weapon,
float  multiplier 
)
private

Apply damage buff multiplier.

Parameters
weaponWeapon component
multiplierDamage multiplier

Definition at line 152 of file BuffSystem.cpp.

References ecs::Weapon::getBaseDamage(), and ecs::Weapon::setDamage().

Here is the call graph for this function:

◆ _applyFireRateBoost()

void ecs::BuffSystem::_applyFireRateBoost ( Weapon weapon,
float  multiplier 
)
private

Apply fire rate buff multiplier.

Parameters
weaponWeapon component
multiplierFire rate multiplier

Definition at line 159 of file BuffSystem.cpp.

References ecs::Weapon::getBaseFireRate(), and ecs::Weapon::setFireRate().

Here is the call graph for this function:

◆ _applyHealthRegen()

void ecs::BuffSystem::_applyHealthRegen ( Health health,
float  deltaTime,
float  regenRate 
)
private

Apply health regeneration.

Parameters
healthHealth component
deltaTimeTime elapsed
regenRateHealth points per second

Definition at line 173 of file BuffSystem.cpp.

References ecs::Health::getCurrentHealth(), ecs::Health::getMaxHealth(), and ecs::Health::setCurrentHealth().

Here is the call graph for this function:

◆ _applyShield()

void ecs::BuffSystem::_applyShield ( Health health,
float  duration 
)
private

Apply shield (invincibility)

Parameters
healthHealth component
durationRemaining shield duration

Definition at line 166 of file BuffSystem.cpp.

References ecs::Health::setInvincibilityTimer(), and ecs::Health::setInvincible().

Here is the call graph for this function:

◆ _applySpeedBoost()

void ecs::BuffSystem::_applySpeedBoost ( Velocity velocity,
float  multiplier 
)
private

Apply speed buff multiplier.

Parameters
velocityVelocity component
multiplierSpeed multiplier

Definition at line 145 of file BuffSystem.cpp.

References ecs::Velocity::getBaseSpeed(), and ecs::Velocity::setSpeed().

Here is the call graph for this function:

◆ _updateBuffTimers()

void ecs::BuffSystem::_updateBuffTimers ( Buff buff,
float  deltaTime 
)
private

Update buff timers and remove expired ones.

Parameters
buffBuff component to update
deltaTimeTime elapsed

Definition at line 42 of file BuffSystem.cpp.

References ecs::DamageBoost, ecs::BuffInstance::duration, ecs::FireRateBoost, ecs::Buff::getBuffsMutable(), ecs::HealthRegen, LOG_INFO, ecs::Shield, ecs::SpeedBoost, and ecs::BuffInstance::type.

Referenced by update().

Here is the call graph for this function:

◆ getComponentMask()

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

Gets the component mask for this system.

Processes entities with Buff component.

Returns
ComponentMask Bitmask for Buff component

Implements ecs::ISystem.

Definition at line 36 of file BuffSystem.cpp.

◆ update()

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

Update buff timers and apply effects.

Decrements buff durations, removes expired buffs, and applies stat modifications to entities based on their active buffs.

Parameters
registryReference to the ECS registry
deltaTimeTime elapsed since last frame (in seconds)

Implements ecs::ISystem.

Definition at line 14 of file BuffSystem.cpp.

References _applyBuffEffects(), _updateBuffTimers(), ecs::Registry::getComponent(), ecs::Buff::hasAnyBuffs(), ecs::Registry::removeComponent(), and ecs::Registry::view().

Here is the call graph for this function:

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