make deconstruction its own system
DeconstructionSystem takes over the demolition queue: it runs the front entry's timer and, when it elapses, removes the building, releases its tiles and credits the partial refund. Simulation::tick calls it directly, in the position tickDeconstruction held. It needs no BeltSystem, unlike its construction counterpart: a belt, splitter or tunnel end is unregistered the moment it is queued, not when the timer completes. It does need the refund sink, so it takes the same addBuildingBlocks callback BuildingSystem holds. startFrontDeconstruction becomes a shared free function rather than moving: BuildingSystem::deconstruct starts the timer when it queues the first entry, and the system restarts it after each completion. Stubbing the refund sink out in the test helper made two tests fail on the refund not arriving — correctly. runTicks now threads the caller's stock through instead. 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
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include "FactoryQueries.h"
|
||||
#include "ConstructionSystem.h"
|
||||
#include "DeconstructionSystem.h"
|
||||
#include "PlacementRules.h"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -125,6 +126,8 @@ void Simulation::initializeSubsystems()
|
||||
[this](const std::string& itemId) -> bool { return isItemUnlocked(itemId); },
|
||||
m_rng);
|
||||
m_constructionSystem = std::make_unique<ConstructionSystem>(m_config);
|
||||
m_deconstructionSystem = std::make_unique<DeconstructionSystem>(
|
||||
m_config, [this](int amount) { m_buildingBlocksStock += amount; });
|
||||
m_shipSystem = std::make_unique<ShipSystem>(m_config, m_admin);
|
||||
m_aiSystem = std::make_unique<AiSystem>(m_config);
|
||||
m_movementIntentSystem = std::make_unique<MovementIntentSystem>();
|
||||
@@ -246,7 +249,7 @@ void Simulation::tick()
|
||||
|
||||
// Construction + production pipeline
|
||||
m_constructionSystem->tick(m_factoryState, m_beltSystem, m_currentTick);
|
||||
m_buildingSystem->tickDeconstruction(m_factoryState, m_currentTick); // parallel to construction
|
||||
m_deconstructionSystem->tick(m_factoryState, m_currentTick); // parallel to construction
|
||||
m_buildingSystem->tickBeltPull(m_factoryState); // step 3
|
||||
m_buildingSystem->tickProduction(m_factoryState, m_currentTick); // step 4
|
||||
m_buildingSystem->tickShipyardProduction(m_factoryState, m_currentTick); // step 4b
|
||||
|
||||
Reference in New Issue
Block a user