40 lines
1.1 KiB
C++
40 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <vector>
|
|
|
|
#include "BeamFiredEvent.h"
|
|
#include "Tick.h"
|
|
|
|
#include "entt/entity/entity.hpp"
|
|
|
|
class BuildingSystem;
|
|
class EntityAdmin;
|
|
class ScrapSystem;
|
|
|
|
// World-mutation system for salvage modules: each module runs a collection cycle
|
|
// on its own cooldown. When a cycle starts it emits a salvage beam toward an
|
|
// in-range scrap pile and schedules the collection of one scrap for mid-beam
|
|
// (kBeamImpactDelayTicks later) — mirroring weapon firing. Also delivers full
|
|
// cargo at a SalvageBay. Runs every tick, independent of behavior selection.
|
|
class SalvagerSystem
|
|
{
|
|
public:
|
|
explicit SalvagerSystem(EntityAdmin& admin);
|
|
|
|
void tick(Tick currentTick, ScrapSystem& scraps, BuildingSystem& buildings,
|
|
std::vector<BeamFiredEvent>& outBeamFiredEvents);
|
|
|
|
private:
|
|
struct PendingCollection
|
|
{
|
|
entt::entity ship;
|
|
entt::entity scrap;
|
|
Tick appliesAt;
|
|
};
|
|
|
|
void applyPendingCollections(Tick currentTick, ScrapSystem& scraps);
|
|
|
|
EntityAdmin& m_admin;
|
|
std::vector<PendingCollection> m_pendingCollections;
|
|
};
|