move the placement rules and the config-dependent queries off BuildingSystem
isPlacementValid, findRotateInPlaceTarget and the bodyCellsWithinWorldBounds helper become PlacementRules.h — where a building may go and what already sits on those tiles, answered from the factory state and the config. getInputPorts and getSiteSplitterInfo join FactoryQueries.h, whose header comment now says plainly that the last two also take the config because answering them means reading a building definition. computeInputPorts goes to PortGeometry.h alongside outputBodyTile/inputBodyTile: it needs only Port and QPoint, so it belongs in core rather than in sim. BuildingSystem is left with no query that reads the factory — its remaining const methods are the emerging/incoming item walks, the checksum fold, and the buffer initialisers. It changes the factory now; it no longer describes it. 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:
@@ -8,15 +8,19 @@
|
||||
#include "Building.h"
|
||||
#include "BuildingId.h"
|
||||
#include "BuildingType.h"
|
||||
#include "BeltSystem.h"
|
||||
#include "FactoryState.h"
|
||||
#include "GameConfig.h"
|
||||
#include "Port.h"
|
||||
|
||||
// Queries and operations over the factory's world data that need nothing but that
|
||||
// data — no config, no belts, no RNG. Free functions rather than BuildingSystem
|
||||
// methods so that callers depend on the data they read instead of on the system
|
||||
// that happens to tick it (see FactoryState.h).
|
||||
//
|
||||
// A helper belongs here only if it is a pure function of FactoryState. Anything
|
||||
// needing GameConfig or the asteroid bound stays on BuildingSystem for now.
|
||||
// Most need nothing but the state. The two at the bottom also take the config,
|
||||
// because answering them means reading a building definition — but still no belts,
|
||||
// no RNG and no system.
|
||||
|
||||
// The building with the given id, or nullptr when no building has it. Construction
|
||||
// sites are not buildings yet — use findSite for those.
|
||||
@@ -52,3 +56,16 @@ const Building* findNearestBuilding(const FactoryState& state, QVector2D worldPo
|
||||
// (REQ-BLD-DECON-QUEUE), or its holding capacity is already taken — emerging
|
||||
// scrap counts against that capacity (REQ-MAT-OUTPUT-EMERGE).
|
||||
bool deliverScrapToSalvageBay(FactoryState& state, BuildingId bayId);
|
||||
|
||||
// Every belt-facing edge of the building or site with this id (REQ-MAT-INPUT-PORTS,
|
||||
// REQ-BLD-BELT-DRAG). Empty when the id is unknown. A site has no stored ports, so
|
||||
// they are derived from its surface mask.
|
||||
std::vector<Port> getInputPorts(const FactoryState& state, const GameConfig& config,
|
||||
BuildingId id);
|
||||
|
||||
// The two output directions and stored filters of a queued Splitter site
|
||||
// (REQ-BLD-SITE-CONFIG), or nullopt if the id is not one. Operational splitters are
|
||||
// configured through BeltSystem by tile instead.
|
||||
std::optional<BeltSystem::SplitterInfo> getSiteSplitterInfo(const FactoryState& state,
|
||||
const GameConfig& config,
|
||||
BuildingId id);
|
||||
|
||||
Reference in New Issue
Block a user