16 auto entities = registry.
view<
Buff>();
18 for (
auto entity : entities) {
38 mask |= (1ULL << getComponentType<Buff>());
46 auto initialSize = buffs.size();
47 buffs.erase(std::remove_if(buffs.begin(), buffs.end(),
55 const char *buffName =
"Unknown";
58 buffName =
"SpeedBoost";
61 buffName =
"DamageBoost";
64 buffName =
"FireRateBoost";
70 buffName =
"HealthRegen";
75 LOG_INFO(
"[BUFF] ", buffName,
" expired");
82 if (buffs.size() < initialSize) {
83 LOG_DEBUG(
"[BUFF] Removed ", (initialSize - buffs.size()),
" expired buff(s)");
90 for (
const auto &b : buffs) {
92 case BuffType::SpeedBoost:
95 _applySpeedBoost(vel, b.value);
99 case BuffType::DamageBoost:
102 _applyDamageBoost(weapon, b.value);
106 case BuffType::FireRateBoost:
109 _applyFireRateBoost(weapon, b.value);
113 case BuffType::Shield:
116 _applyShield(health, b.duration);
120 case BuffType::HealthRegen:
124 _applyHealthRegen(health, 0.016f, b.value);
129 case BuffType::MultiShot:
130 case BuffType::DoubleShot:
131 case BuffType::TripleShot:
132 case BuffType::PiercingShot:
133 case BuffType::HomingShot:
137 case BuffType::MaxHealthIncrease:
145 void BuffSystem::_applySpeedBoost(
Velocity &velocity,
float multiplier) {
148 float newSpeed = baseSpeed * multiplier;
152 void BuffSystem::_applyDamageBoost(
Weapon &weapon,
float multiplier) {
155 int newDamage =
static_cast<int>(baseDamage * multiplier);
159 void BuffSystem::_applyFireRateBoost(
Weapon &weapon,
float multiplier) {
162 float newFireRate = baseFireRate * multiplier;
166 void BuffSystem::_applyShield(
Health &health,
float duration) {
167 if (duration > 0.0f) {
173 void BuffSystem::_applyHealthRegen(
Health &health,
float deltaTime,
float regenRate) {
177 if (currentHealth < maxHealth) {
178 float regenAmount = regenRate * deltaTime;
179 int newHealth = std::min(currentHealth +
static_cast<int>(regenAmount), maxHealth);
void _applyBuffEffects(Address address, Registry ®istry, const Buff &buff)
Apply buff effects to entity stats.
void update(Registry ®istry, float deltaTime) override
Update buff timers and apply effects.
void _updateBuffTimers(Buff &buff, float deltaTime)
Update buff timers and remove expired ones.
ComponentMask getComponentMask() const override
Gets the component mask for this system.
Component managing active buffs on an entity.
std::vector< BuffInstance > & getBuffsMutable()
Get mutable reference to buffs (for system updates)
const std::vector< BuffInstance > & getBuffs() const
Get all active buffs.
bool hasAnyBuffs() const
Check if any buffs are active.
Component representing entity health and invincibility.
int getCurrentHealth() const
Get current health points.
void setInvincible(bool invincible)
Set invincibility state.
void setInvincibilityTimer(float timer)
Set invincibility timer.
void setCurrentHealth(int health)
Set current health.
int getMaxHealth() const
Get maximum health points.
Manages entities, their signatures and component type registrations.
void removeComponent(Address address)
Remove a component from an entity.
T & getComponent(Address address)
Get a component from an entity.
bool hasComponent(Address address)
Check if an entity has a specific component.
std::vector< Address > view()
Get all entities that have a specific set of components.
Component representing movement direction and speed.
void setSpeed(float speed)
Set the movement speed.
float getBaseSpeed() const
Get the base movement speed (before buffs).
Component for entities capable of shooting projectiles.
float getBaseFireRate() const
Get base fire rate (before buffs).
void setFireRate(float fireRate)
Set fire rate.
void setDamage(float damage)
Set damage value.
int getBaseDamage() const
Get base damage (before buffs).
Maximum number of distinct component types supported by the Registry.
@ DamageBoost
Increases weapon damage.
@ FireRateBoost
Increases fire rate.
@ Shield
Temporary invincibility.
@ HealthRegen
Regenerates health over time.
@ SpeedBoost
Increases movement speed.
std::uint32_t Address
Type used to represent an entity address/ID.
std::uint64_t ComponentMask
Type alias for component bitmask.
Individual buff with its properties.
float duration
Remaining duration (0.0f = permanent)
BuffType type
Type of buff.