separate what buildings are from what flows through them
BuildingSystem was four unrelated jobs in one class: building lifecycle, building configuration, the per-tick material flow, and (until last commit) the checksum. The flow was the odd one out -- it is what the RNG, the ship spawner and the unlock test were held for, none of which placement, rotation or demolition has any business reaching. Tick steps 3 to 5 move to a new ProductionSystem: tickBeltPull, tickProduction, tickShipyardProduction, tickOutputBelts, their five private helpers and rollOutputGroup. The cut is clean in both directions -- nothing in the block called a topology or configuration method, and nothing outside it called the helpers -- so the bodies move verbatim; a scripted comparison against the old file confirms all nine differ only by class qualifier, the m_belts -> belts rename, and the two added parameters. (Seven em dashes in comments became `--`; the new file is ASCII, as the guidelines require.) Belts arrive per tick rather than being held, matching ConstructionSystem, and only the two methods that touch them take the parameter. BuildingSystem is left holding the config and the belts, and its constructor takes exactly those two. The arena constructs no ProductionSystem at all: it stages ships directly and never runs a factory. Determinism rests on the RNG stream: step 4's weighted output-group pick is the factory's only draw, so the four calls must keep their order and position in Simulation::tick. They do, and the tick-order section now says why, since no test can catch a reordering here. 913 lines of BuildingSystem.cpp become 444 there and 483 in ProductionSystem.cpp. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ne3mejABZoLWKLh8fgpM3x
This commit is contained in:
@@ -47,12 +47,9 @@ ArenaSimulation::ArenaSimulation(const GameConfig& gameConfig,
|
||||
{
|
||||
m_factoryState = makeFactoryState(m_gameConfig);
|
||||
|
||||
m_buildingSystem = std::make_unique<BuildingSystem>(
|
||||
m_gameConfig,
|
||||
m_beltSystem,
|
||||
[](const std::string&, QVector2D, const std::optional<ShipLayoutConfig>&) {},
|
||||
[](const std::string&) -> bool { return true; },
|
||||
m_rng);
|
||||
// No ProductionSystem here: the arena stages ships directly and never runs a
|
||||
// factory, so nothing ticks material flow (ProductionSystem.h).
|
||||
m_buildingSystem = std::make_unique<BuildingSystem>(m_gameConfig, m_beltSystem);
|
||||
|
||||
m_shipSystem = std::make_unique<ShipSystem>(m_gameConfig, m_admin);
|
||||
// Arena fights are symmetric and aggressive: player-faction ships must not
|
||||
|
||||
Reference in New Issue
Block a user