implement waves
This commit is contained in:
61
src/lib/sim/CombatSystem.h
Normal file
61
src/lib/sim/CombatSystem.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <vector>
|
||||
|
||||
#include <QVector2D>
|
||||
|
||||
#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<FireEvent>& outFireEvents);
|
||||
|
||||
private:
|
||||
// Process one ship's weapon for this tick.
|
||||
void resolveShipWeapon(Ship& ship, Tick currentTick,
|
||||
ShipSystem& ships,
|
||||
BuildingSystem& buildings,
|
||||
std::vector<FireEvent>& out);
|
||||
|
||||
// Process one defence-station's weapon for this tick.
|
||||
void resolveStationWeapon(Building& station, Tick currentTick,
|
||||
ShipSystem& ships,
|
||||
BuildingSystem& buildings,
|
||||
std::vector<FireEvent>& out);
|
||||
|
||||
// Find the nearest valid target for a defence station within its range.
|
||||
// Enemy stations target player ships + HQ + PlayerDefenceStation.
|
||||
// Player stations target enemy ships only.
|
||||
std::optional<EntityId> acquireStationTarget(
|
||||
const Building& station, bool stationIsEnemy,
|
||||
const ShipSystem& ships,
|
||||
const BuildingSystem& buildings) const;
|
||||
|
||||
// Return the world position of the entity, or nullopt if it no longer exists.
|
||||
std::optional<QVector2D> targetPosition(EntityId id,
|
||||
const ShipSystem& ships,
|
||||
const BuildingSystem& buildings) const;
|
||||
|
||||
const GameConfig& m_config;
|
||||
};
|
||||
Reference in New Issue
Block a user