move the placement rules and the config-dependent queries off BuildingSystem

This commit is contained in:
2026-08-05 06:49:49 +02:00
parent 537597c854
commit d87d063b10
14 changed files with 340 additions and 274 deletions

View File

@@ -1,4 +1,5 @@
#include "GameWorldView.h"
#include "PlacementRules.h"
#include "FactoryQueries.h"
#include "ProductionRules.h"
@@ -662,7 +663,7 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
// Terrain and world-bounds validity are owned by the simulation
// (REQ-BLD-PLACE-VALID); the presentation layer only adds the occupancy /
// rotate-in-place check.
if (!m_sim->getBuildings().isPlacementValid(type, anchor, rot))
if (!isPlacementValid(m_sim->getFactoryState(), m_sim->getConfig(), type, anchor, rot))
{
return false;
}
@@ -683,7 +684,7 @@ bool GameWorldView::isValidPlacement(BuildingType type, QPoint anchor,
if (anyOccupied)
{
return m_sim->getBuildings().findRotateInPlaceTarget(type, anchor, rot).has_value();
return findRotateInPlaceTarget(m_sim->getFactoryState(), m_sim->getConfig(), type, anchor, rot).has_value();
}
return true;
}
@@ -865,8 +866,7 @@ void GameWorldView::placeBlueprintAtTile(QPoint center)
for (const BlueprintBuilding& bb : bp.buildings)
{
if (!m_sim->isBuildingUnlocked(bb.type)) { continue; }
if (m_sim->getBuildings().findRotateInPlaceTarget(
bb.type, center + bb.offset, bb.rotation).has_value())
if (findRotateInPlaceTarget(m_sim->getFactoryState(), m_sim->getConfig(), bb.type, center + bb.offset, bb.rotation).has_value())
{
continue;
}
@@ -880,7 +880,7 @@ void GameWorldView::placeBlueprintAtTile(QPoint center)
if (!m_sim->isBuildingUnlocked(bb.type)) { continue; }
const QPoint anchor = center + bb.offset;
const std::optional<BuildingId> rotateTarget =
m_sim->getBuildings().findRotateInPlaceTarget(bb.type, anchor, bb.rotation);
findRotateInPlaceTarget(m_sim->getFactoryState(), m_sim->getConfig(), bb.type, anchor, bb.rotation);
if (rotateTarget.has_value())
{
std::shared_ptr<RotateInPlaceCommand> rotateCommand =
@@ -1016,7 +1016,7 @@ void GameWorldView::placeAtTile(QPoint tile)
}
const std::optional<BuildingId> rotateTarget =
m_sim->getBuildings().findRotateInPlaceTarget(type, tile, m_ghostRotation);
findRotateInPlaceTarget(m_sim->getFactoryState(), m_sim->getConfig(), type, tile, m_ghostRotation);
if (rotateTarget.has_value())
{
std::shared_ptr<RotateInPlaceCommand> command =
@@ -1080,7 +1080,7 @@ void GameWorldView::recomputeBeltDragPath(QPoint cursorTile)
if (targetId.has_value() && targetType.has_value()
&& *targetType != BuildingType::Belt)
{
const std::vector<Port> inputPorts = m_sim->getBuildings().getInputPorts(*targetId);
const std::vector<Port> inputPorts = getInputPorts(m_sim->getFactoryState(), m_sim->getConfig(), *targetId);
std::optional<Port> best;
float bestDistanceSq = 0.0f;
for (const Port& port : inputPorts)
@@ -1124,8 +1124,7 @@ std::vector<GameWorldView::BeltDragResolved> GameWorldView::resolveBeltDragPath(
{
BeltDragResolved item;
const std::optional<BuildingId> rotateTarget =
m_sim->getBuildings().findRotateInPlaceTarget(
BuildingType::Belt, entry.tile, entry.rotation);
findRotateInPlaceTarget(m_sim->getFactoryState(), m_sim->getConfig(), BuildingType::Belt, entry.tile, entry.rotation);
if (rotateTarget.has_value())
{
// A tile holding only a belt (or belt site) is re-oriented, no cost.

View File

@@ -314,7 +314,7 @@ void SelectedBuildingPanel::buildSingle(BuildingId id)
std::optional<BeltSystem::SplitterInfo> info;
if (m_singleIsSite)
{
info = m_sim->getBuildings().getSiteSplitterInfo(id);
info = getSiteSplitterInfo(m_sim->getFactoryState(), m_sim->getConfig(), id);
}
else
{