migrate every factory query off BuildingSystem onto the free functions
The eleven forwarding members added last commit are gone; callers now read the data directly through FactoryQueries.h. Simulation and ArenaSimulation expose getFactoryState() so the UI, the balancing view and the tests can reach it. isQueuedForDeconstruction joined the free functions along the way — it only reaches findBuilding, so it was state-pure too. No facade was introduced. The chained form was the reason one looked attractive, but rewriting sim.getBuildings().findBuilding(id) to findBuilding(sim.getFactoryState(), id) turned out to be mechanical, and the result says which data is read rather than which system happens to own it. BuildingSystem.cpp is down to 1735 lines and no longer answers questions about the factory — it only changes it. What remains on it are the mutators, the tick phases, and the queries that also need GameConfig. 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:
@@ -77,6 +77,12 @@ bool isTileOccupied(const FactoryState& state, QPoint tile)
|
||||
return state.grid.isOccupied(tile);
|
||||
}
|
||||
|
||||
bool isQueuedForDeconstruction(const FactoryState& state, BuildingId id)
|
||||
{
|
||||
const Building* building = findBuilding(state, id);
|
||||
return building && building->queuedForDeconstruction;
|
||||
}
|
||||
|
||||
const Building* findNearestBuilding(const FactoryState& state, QVector2D worldPos,
|
||||
BuildingType type)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user