Ten queries that read nothing but FactoryState become free functions in FactoryQueries.h; the BuildingSystem methods stay as one-line forwards, so no existing caller moves yet. That lets the AI path drop its dependency on the system entirely. AiSystem, SalvagerSystem, DeliverScrapEvaluator and DeliverScrapExecutor took a BuildingSystem& purely to call findBuilding, findNearestBuilding and deliverScrapToSalvageBay — all three are state-pure — so they now take FactoryState& and say what they actually read. Four forward declarations of BuildingSystem go with them. No facade: the queries are plain free functions over the data. A facade was considered to spare the ~180 UI call sites, but the AI needed only the data and would have been given GameConfig it has no use for. isProductionBuildingType moves to BuildingType.h beside isAutoRecipeBuildingType and isBeltSubsystemType rather than being copied into the new file. Verified with a golden-checksum capture before and after — all four sample ticks identical. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YHcUerKAZKWNvSKJxYKbnG
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include "FactoryQueries.h"
|
|
|
|
#include <vector>
|
|
|
|
#include "BeamFiredEvent.h"
|
|
#include "Tick.h"
|
|
|
|
#include "entt/entity/entity.hpp"
|
|
|
|
class EntityAdmin;
|
|
class DebrisSystem;
|
|
|
|
// 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 piece of debris 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, DebrisSystem& debris, FactoryState& state,
|
|
std::vector<BeamFiredEvent>& outBeamFiredEvents);
|
|
|
|
private:
|
|
struct PendingCollection
|
|
{
|
|
entt::entity ship;
|
|
entt::entity debris;
|
|
Tick appliesAt;
|
|
};
|
|
|
|
void applyPendingCollections(Tick currentTick, DebrisSystem& debris);
|
|
|
|
EntityAdmin& m_admin;
|
|
std::vector<PendingCollection> m_pendingCollections;
|
|
};
|