82 bool isPermanent = (duration <= 0.0f);
85 for (
auto &buff :
_buffs) {
86 if (buff.type == type) {
88 buff.duration = duration;
90 buff.isPermanent = isPermanent;
96 _buffs.emplace_back(type, duration, value, isPermanent);
105 [type](
const BuffInstance &b) { return b.type == type; }),
115 for (
const auto &buff :
_buffs) {
116 if (buff.type == type)
128 for (
const auto &buff :
_buffs) {
129 if (buff.type == type)
Component managing active buffs on an entity.
bool hasBuff(BuffType type) const
Check if entity has a specific buff.
float getBuffValue(BuffType type) const
Get buff value for a specific type.
ComponentType getType() const override
Get the component type ID.
void removeBuff(BuffType type)
Remove a specific buff.
std::vector< BuffInstance > & getBuffsMutable()
Get mutable reference to buffs (for system updates)
std::vector< BuffInstance > _buffs
Active buffs on this entity.
void addBuff(BuffType type, float duration, float value)
Add a new buff.
void clearAllBuffs()
Clear all buffs.
const std::vector< BuffInstance > & getBuffs() const
Get all active buffs.
Buff()=default
Default constructor.
Buff(BuffType type, float duration, float value)
Constructor with initial buff.
bool hasAnyBuffs() const
Check if any buffs are active.
Base interface for all ECS components.
Maximum number of distinct component types supported by the Registry.
BuffType
Types of buffs that can be applied to entities.
@ PiercingShot
Projectiles pierce through enemies.
@ TripleShot
Fire three projectiles at once.
@ DamageBoost
Increases weapon damage.
@ HomingShot
Projectiles home towards enemies.
@ FireRateBoost
Increases fire rate.
@ MaxHealthIncrease
Permanently increase max health.
@ Shield
Temporary invincibility.
@ HealthRegen
Regenerates health over time.
@ SpeedBoost
Increases movement speed.
@ MultiShot
Shoot in multiple directions.
@ DoubleShot
Fire two projectiles at once.
std::size_t ComponentType
Type alias for component identification.
Individual buff with its properties.
BuffInstance(BuffType t, float dur, float val, bool perm=false)
bool isPermanent
True if buff never expires.
float duration
Remaining duration (0.0f = permanent)
BuffType type
Type of buff.
float value
Buff value (multiplier or absolute value)