implement ship behaviors
This commit is contained in:
@@ -9,22 +9,56 @@
|
||||
#include "GameConfig.h"
|
||||
#include "Ship.h"
|
||||
|
||||
class BuildingSystem;
|
||||
class ScrapSystem;
|
||||
|
||||
class ShipSystem
|
||||
{
|
||||
public:
|
||||
ShipSystem(const GameConfig& config,
|
||||
std::function<EntityId()> allocateId);
|
||||
|
||||
EntityId spawn(const std::string& blueprintId, int level, QVector2D position);
|
||||
// isEnemy defaults to false; set true for enemy-faction ships (step 7 wave spawning).
|
||||
EntityId spawn(const std::string& blueprintId, int level, QVector2D position,
|
||||
bool isEnemy = false);
|
||||
void despawn(EntityId id);
|
||||
|
||||
const Ship* findShip(EntityId id) const;
|
||||
std::vector<Ship> allShips() const;
|
||||
void forEach(std::function<void(Ship&)> fn);
|
||||
|
||||
// -- Behavior tick methods (tick-order step 7) ---------------------------
|
||||
|
||||
// Reset all movement intents to priority 0 before behavior systems run.
|
||||
void clearMovementIntents();
|
||||
|
||||
// Priority 4: low-HP ships retreat to homePos.
|
||||
void tickHomeReturn();
|
||||
|
||||
// Priority 3: combat ships acquire targets and advance toward them.
|
||||
void tickThreatResponse(const BuildingSystem& buildings);
|
||||
|
||||
// Priority 2: repair ships find and heal damaged friendly ships/stations.
|
||||
void tickRepairBehavior(BuildingSystem& buildings);
|
||||
|
||||
// Priority 1: salvage ships collect scrap and deliver it.
|
||||
void tickScrapCollector(ScrapSystem& scraps, const BuildingSystem& buildings);
|
||||
|
||||
// -- Movement (tick-order step 10) ---------------------------------------
|
||||
void tickMovement();
|
||||
|
||||
private:
|
||||
const ShipDef* findShipDef(const std::string& blueprintId) const;
|
||||
|
||||
// True if the entity identified by id is alive and within range of ship.
|
||||
// Searches both the ship list and (for buildings) the supplied BuildingSystem.
|
||||
bool isTargetValid(EntityId id, float range, const Ship& ship,
|
||||
const BuildingSystem& buildings) const;
|
||||
|
||||
// Heal the ship with the given id by amount, clamped to maxHp.
|
||||
// Returns false if the ship is not found.
|
||||
bool healShip(EntityId id, float amount);
|
||||
|
||||
const GameConfig& m_config;
|
||||
std::function<EntityId()> m_allocateId;
|
||||
std::vector<Ship> m_ships;
|
||||
|
||||
Reference in New Issue
Block a user