#pragma once #include #include #include #include "Building.h" #include "EntityId.h" #include "FireEvent.h" #include "GameConfig.h" #include "Ship.h" #include "Tick.h" class BuildingSystem; class ShipSystem; // Resolves all weapon fire for ships and defence stations (tick-order step 8). // REQ-SHP-FIRING, REQ-DEF-PLAYER-FIRE, REQ-DEF-ENEMY-FIRE. class CombatSystem { public: explicit CombatSystem(const GameConfig& config); // Advance weapon cooldowns, acquire targets for stations, fire when ready, // apply damage, and append FireEvents. Damage is applied immediately via // ShipSystem::damageShip and BuildingSystem::damageBuilding; step 9 // removes entities whose HP dropped to zero or below. void tick(Tick currentTick, ShipSystem& ships, BuildingSystem& buildings, std::vector& outFireEvents); private: // Process one ship's weapon for this tick. void resolveShipWeapon(Ship& ship, Tick currentTick, ShipSystem& ships, BuildingSystem& buildings, std::vector& out); // Process one defence-station's weapon for this tick. void resolveStationWeapon(Building& station, Tick currentTick, ShipSystem& ships, BuildingSystem& buildings, std::vector& out); // Find the nearest valid target for a defence station within its range. // Both enemy and player stations target ships of the opposing faction only. std::optional acquireStationTarget( const Building& station, bool stationIsEnemy, const ShipSystem& ships) const; // Return the world position of the entity, or nullopt if it no longer exists. std::optional targetPosition(EntityId id, const ShipSystem& ships, const BuildingSystem& buildings) const; const GameConfig& m_config; };