free the buffer setup and belt registration from BuildingSystem
Prerequisite for ConstructionSystem completing a building itself rather than handing a finished site back: materialisation needs the buffer initialisers and the BeltSystem registration, and both were BuildingSystem members. initBuffers turned out to need nothing at all — it works purely on the Building and RecipeDef it is given. The other three need only the config. reregisterBeltTile takes BeltSystem and the config; it stays shared rather than moving, because cancelDeconstruction and rotateInPlace use it too and are staying on BuildingSystem. 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:
39
src/lib/sim/BuildingBuffers.h
Normal file
39
src/lib/sim/BuildingBuffers.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "BeltSystem.h"
|
||||
#include "Building.h"
|
||||
#include "GameConfig.h"
|
||||
#include "ItemType.h"
|
||||
#include "RecipesConfig.h"
|
||||
|
||||
// Setting a building up when it starts existing or is reconfigured: sizing its
|
||||
// input/output buffers from what it will produce, and handing belt-like types back
|
||||
// to BeltSystem. Free functions over the config and the building — they read no
|
||||
// factory state, so both BuildingSystem and ConstructionSystem can use them.
|
||||
|
||||
// Buffers for a building running one known recipe: inputs capped at twice each
|
||||
// ingredient's per-cycle amount, output at twice the per-cycle total (one cycle's
|
||||
// max for a Reprocessing Plant, REQ-MAT-OUTPUT-BUFFER-REPROCESSING).
|
||||
void initBuffers(Building& b, const RecipeDef& recipe);
|
||||
|
||||
// Buffers for an auto-recipe building (Smelter, Reprocessing Plant), unioned over
|
||||
// every recipe of its type (REQ-BLD-SMELTER, REQ-BLD-REPROCESSING).
|
||||
void initAutoBuffers(const GameConfig& config, Building& b);
|
||||
|
||||
// Buffers for a shipyard: its schematic's materials plus those of every placed
|
||||
// module (REQ-BLD-SHIPYARD).
|
||||
void initShipyardBuffers(const GameConfig& config, Building& b);
|
||||
|
||||
// The Salvage Bay holds no recipe inputs; its output capacity is config-defined
|
||||
// (REQ-BLD-SALVAGE-BAY).
|
||||
void initSalvageBayBuffer(const GameConfig& config, Building& b);
|
||||
|
||||
// Registers a belt, splitter or tunnel end with BeltSystem. A splitter's filters
|
||||
// live in BeltSystem and are lost by removeTile, so they are passed back in
|
||||
// (REQ-BLD-SPLITTER). No-op for every other building type.
|
||||
void reregisterBeltTile(BeltSystem& belts, const GameConfig& config,
|
||||
const Building& building,
|
||||
const std::vector<ItemType>& splitterFilterA,
|
||||
const std::vector<ItemType>& splitterFilterB);
|
||||
Reference in New Issue
Block a user