Code: include/controllers/combat/CombatController.hpp, src/controllers/combat/CombatController.cpp
CombatController is the player-facing combat helper used by gameplay and demo states. It is frame-updatable because it owns:
- attack cooldown timing
- stamina regeneration
- reusable query buffers for nearby AI targets
The controller performs ranged projectile attacks when the equipped weapon supports them, consumes compatible ammunition through EDM inventory, falls back to a melee weapon when one is available, performs melee hit detection by querying nearby AI/EDM entities directly, applies damage through the DamageEvent gameplay path, and updates the gameplay event log.
bool tryAttack();
void update(float deltaTime);Constants:
ATTACK_STAMINA_COST = 10.0f
STAMINA_REGEN_RATE = 15.0f
ATTACK_COOLDOWN = 0.5ftryAttack()checks cooldown and player stamina.performAttack()verifies that a ranged attack can fire or that a melee fallback can be equipped.- successful ranged attacks consume ammunition and create a projectile.
- melee attacks query nearby handles using a reused buffer.
- valid melee targets are damaged through the current player/EDM combat path.
- stamina, cooldown, and player attacking state are committed only after an attack can actually happen.
update()regenerates stamina.
CombatController does not own target-frame HUD state. It emits combat damage through the event path; HudController subscribes to combat events and supplies target label/health data to the active state. States should use the dedicated combat HUD helpers in UIManager instead of rebuilding target widgets by hand.
- The controller owns a reusable
m_nearbyHandlesBufferto avoid per-frame allocations. - The controller updates the gameplay event log as part of player combat feedback.