hand BuildingSystem the belts per call, as its siblings get them

The last system holding a piece of the world as a member. ConstructionSystem and
ProductionSystem take the transport layer as a tick argument; BuildingSystem kept
a BeltSystem& from construction, so the same object arrived two different ways
depending on which system you were reading.

Three methods need it -- deconstruct, cancelDeconstruction and rotateInPlace, all
of which register or unregister a belt tile -- and they now take it after the
state, in the argument order the other systems use. The constructor is down to
the config alone.

CombatSystemTest's fixture kept a BeltSystem only to pass it here, so that goes
too.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
2026-08-20 10:48:57 +02:00
parent 19137aaeec
commit 75c049fa67
7 changed files with 47 additions and 47 deletions

View File

@@ -36,7 +36,7 @@
class BuildingSystem
{
public:
BuildingSystem(const GameConfig& config, BeltSystem& belts);
explicit BuildingSystem(const GameConfig& config);
// -- Placement / deconstruct ------------------------------------------------
// Returns the new entity id, or nullopt if the placement falls outside the
@@ -60,13 +60,14 @@ public:
// queue (REQ-BLD-DECON-QUEUE) and stops operating at once; its (partial) refund is
// credited later, on completion, by DeconstructionSystem. No-op for unknown ids and
// for a building already queued.
void deconstruct(FactoryState& state, BuildingId id, Tick currentTick);
void deconstruct(FactoryState& state, BeltSystem& belts, BuildingId id,
Tick currentTick);
// Take a building back out of the deconstruction queue before it is removed
// (REQ-BLD-DECON-QUEUE). Clears its queued flag and resumes operation
// (re-registering belt/tunnel/splitter tiles); discards deconstruction
// progress and credits no refund. No-op if the id is not queued.
void cancelDeconstruction(FactoryState& state, BuildingId id);
void cancelDeconstruction(FactoryState& state, BeltSystem& belts, BuildingId id);
// Set the recipe (or schematic id for shipyard) on a building or queued
// construction site. Clears both buffers on an operational building.
@@ -99,7 +100,8 @@ public:
// Rotate an existing building or construction site to newRotation in place.
// For belt-type operational buildings, re-registers with BeltSystem (items
// currently on the tile are discarded by BeltSystem::removeTile).
void rotateInPlace(FactoryState& state, BuildingId id, Rotation newRotation);
void rotateInPlace(FactoryState& state, BeltSystem& belts, BuildingId id,
Rotation newRotation);
// Register / unregister tile occupancy for ECS station entities.
void registerTileOccupancy(FactoryState& state, const std::vector<QPoint>& cells, BuildingId ownerPlaceholder);
@@ -116,11 +118,9 @@ public:
void forEachBuilding(FactoryState& state, std::function<void(Building&)> fn);
private:
// No world data here: the factory arrives per call (FactoryState.h). The config says
// what a building costs, occupies and can run; the belts are what a placed, rotated or
// demolished belt tile must be registered with and unregistered from. Nothing else --
// no RNG and no callbacks, those having gone to ProductionSystem with the material
// flow that needed them.
// The config alone: what a building costs, occupies and can run. No world data --
// the factory and the transport layer both arrive per call, as they do for
// ConstructionSystem and ProductionSystem (FactoryState.h) -- and no RNG or callbacks,
// those having gone to ProductionSystem with the material flow that needed them.
const GameConfig& m_config;
BeltSystem& m_belts;
};