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

Component managing active buffs on an entity. More...

#include <Buff.hpp>

Inheritance diagram for ecs::Buff:
Inheritance graph
Collaboration diagram for ecs::Buff:
Collaboration graph

Public Member Functions

 Buff ()=default
 Default constructor.
 
 Buff (BuffType type, float duration, float value)
 Constructor with initial buff.
 
 ~Buff () override=default
 
void addBuff (BuffType type, float duration, float value)
 Add a new buff.
 
void removeBuff (BuffType type)
 Remove a specific buff.
 
bool hasBuff (BuffType type) const
 Check if entity has a specific buff.
 
float getBuffValue (BuffType type) const
 Get buff value for a specific type.
 
const std::vector< BuffInstance > & getBuffs () const
 Get all active buffs.
 
std::vector< BuffInstance > & getBuffsMutable ()
 Get mutable reference to buffs (for system updates)
 
bool hasAnyBuffs () const
 Check if any buffs are active.
 
void clearAllBuffs ()
 Clear all buffs.
 
ComponentType getType () const override
 Get the component type ID.
 
- Public Member Functions inherited from ecs::IComponent
virtual ~IComponent ()=default
 Virtual destructor.
 

Private Attributes

std::vector< BuffInstance_buffs
 Active buffs on this entity.
 

Detailed Description

Component managing active buffs on an entity.

Stores and manages multiple active buffs with their durations. Supports both temporary (time-limited) and permanent buffs.

Definition at line 58 of file Buff.hpp.

Constructor & Destructor Documentation

◆ Buff() [1/2]

ecs::Buff::Buff ( )
default

Default constructor.

◆ Buff() [2/2]

ecs::Buff::Buff ( BuffType  type,
float  duration,
float  value 
)
inline

Constructor with initial buff.

Parameters
typeType of buff
durationDuration in seconds (0.0f for permanent)
valueBuff value/multiplier

Definition at line 71 of file Buff.hpp.

References addBuff().

Here is the call graph for this function:

◆ ~Buff()

ecs::Buff::~Buff ( )
overridedefault

Member Function Documentation

◆ addBuff()

void ecs::Buff::addBuff ( BuffType  type,
float  duration,
float  value 
)
inline

Add a new buff.

Parameters
typeType of buff
durationDuration in seconds (0.0f for permanent)
valueBuff value/multiplier

Definition at line 81 of file Buff.hpp.

References _buffs.

Referenced by Buff(), and ecs::CollisionSystem::handlePickup().

◆ clearAllBuffs()

void ecs::Buff::clearAllBuffs ( )
inline

Clear all buffs.

Definition at line 156 of file Buff.hpp.

References _buffs.

◆ getBuffs()

const std::vector< BuffInstance > & ecs::Buff::getBuffs ( ) const
inline

Get all active buffs.

Returns
Vector of all buff instances

Definition at line 139 of file Buff.hpp.

References _buffs.

Referenced by ecs::BuffSystem::_applyBuffEffects().

◆ getBuffsMutable()

std::vector< BuffInstance > & ecs::Buff::getBuffsMutable ( )
inline

Get mutable reference to buffs (for system updates)

Returns
Mutable vector reference

Definition at line 145 of file Buff.hpp.

References _buffs.

Referenced by ecs::BuffSystem::_updateBuffTimers().

◆ getBuffValue()

float ecs::Buff::getBuffValue ( BuffType  type) const
inline

Get buff value for a specific type.

Parameters
typeType of buff
Returns
Buff value, or 1.0f if not found

Definition at line 127 of file Buff.hpp.

References _buffs.

◆ getType()

ComponentType ecs::Buff::getType ( ) const
inlineoverridevirtual

Get the component type ID.

Returns
ComponentType Unique ID for Buff component

Implements ecs::IComponent.

Definition at line 162 of file Buff.hpp.

◆ hasAnyBuffs()

bool ecs::Buff::hasAnyBuffs ( ) const
inline

Check if any buffs are active.

Returns
True if at least one buff is active

Definition at line 151 of file Buff.hpp.

References _buffs.

Referenced by ecs::BuffSystem::update().

◆ hasBuff()

bool ecs::Buff::hasBuff ( BuffType  type) const
inline

Check if entity has a specific buff.

Parameters
typeType of buff to check
Returns
True if buff is active

Definition at line 114 of file Buff.hpp.

References _buffs.

Referenced by ecs::WeaponSystem::fireChargedShot(), and ecs::WeaponSystem::fireWeapon().

◆ removeBuff()

void ecs::Buff::removeBuff ( BuffType  type)
inline

Remove a specific buff.

Parameters
typeType of buff to remove

Definition at line 103 of file Buff.hpp.

References _buffs.

Member Data Documentation

◆ _buffs

std::vector<BuffInstance> ecs::Buff::_buffs
private

Active buffs on this entity.

Definition at line 165 of file Buff.hpp.

Referenced by addBuff(), clearAllBuffs(), getBuffs(), getBuffsMutable(), getBuffValue(), hasAnyBuffs(), hasBuff(), and removeBuff().


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