move the asteroid width bound into FactoryState

This commit is contained in:
2026-08-05 06:45:33 +02:00
parent 0b7e94b4e4
commit 1fb63cce4e
3 changed files with 9 additions and 4 deletions

View File

@@ -40,8 +40,8 @@ BuildingSystem::BuildingSystem(const GameConfig& config,
, m_spawnShip(std::move(spawnShip)) , m_spawnShip(std::move(spawnShip))
, m_isItemUnlocked(std::move(isItemUnlocked)) , m_isItemUnlocked(std::move(isItemUnlocked))
, m_rng(rng) , m_rng(rng)
, m_asteroidWidth_tiles(config.world.regions.asteroidWidth_tiles)
{ {
m_state.asteroidWidth_tiles = config.world.regions.asteroidWidth_tiles;
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -340,7 +340,7 @@ bool BuildingSystem::bodyCellsWithinWorldBounds(const std::vector<QPoint>& bodyC
QPoint anchor) const QPoint anchor) const
{ {
const int heightTiles = m_config.world.heightTiles; const int heightTiles = m_config.world.heightTiles;
const int leftEdgeX = -m_asteroidWidth_tiles; const int leftEdgeX = -m_state.asteroidWidth_tiles;
for (const QPoint& cell : bodyCells) for (const QPoint& cell : bodyCells)
{ {
const QPoint worldCell = anchor + cell; const QPoint worldCell = anchor + cell;

View File

@@ -77,7 +77,7 @@ public:
// Sets the current buildable asteroid width in tiles. Grows the left // Sets the current buildable asteroid width in tiles. Grows the left
// placement bound as the player unlocks asteroid expansions (REQ-EXP-UNLOCK). // placement bound as the player unlocks asteroid expansions (REQ-EXP-UNLOCK).
// Defaults to world.regions.asteroid_width_tiles at construction. // Defaults to world.regions.asteroid_width_tiles at construction.
void setAsteroidWidth_tiles(int widthTiles) { m_asteroidWidth_tiles = widthTiles; } void setAsteroidWidth_tiles(int widthTiles) { m_state.asteroidWidth_tiles = widthTiles; }
// Mark a building or construction site for demolition (REQ-BLD-DECONSTRUCT). // Mark a building or construction site for demolition (REQ-BLD-DECONSTRUCT).
// A construction site is removed instantly and the full cost is returned. // A construction site is removed instantly and the full cost is returned.
@@ -298,5 +298,4 @@ private:
const std::optional<ShipLayoutConfig>&)> m_spawnShip; const std::optional<ShipLayoutConfig>&)> m_spawnShip;
std::function<bool(const std::string&)> m_isItemUnlocked; std::function<bool(const std::string&)> m_isItemUnlocked;
std::mt19937& m_rng; std::mt19937& m_rng;
int m_asteroidWidth_tiles;
}; };

View File

@@ -45,4 +45,10 @@ struct FactoryState
// The authority on which building owns which tile; every placement and removal // The authority on which building owns which tile; every placement and removal
// path claims and releases its body cells here. // path claims and releases its body cells here.
BuildingGrid grid; BuildingGrid grid;
// Current buildable asteroid width, the left bound for placement. Grows as the
// player buys expansions (REQ-EXP-UNLOCK). Deliberately not checksummed: it is
// derived from config and Simulation's expansion count, which is folded already.
// Seeded from config by BuildingSystem's constructor.
int asteroidWidth_tiles = 0;
}; };