migrate every factory query off BuildingSystem onto the free functions
This commit is contained in:
@@ -241,11 +241,11 @@ std::vector<Port> BuildingSystem::computeInputPorts(
|
||||
|
||||
std::vector<Port> BuildingSystem::getInputPorts(BuildingId id) const
|
||||
{
|
||||
if (const Building* building = findBuilding(id))
|
||||
if (const Building* building = findBuilding(m_state, id))
|
||||
{
|
||||
return building->inputPorts;
|
||||
}
|
||||
if (const ConstructionSite* site = findSite(id))
|
||||
if (const ConstructionSite* site = findSite(m_state, id))
|
||||
{
|
||||
// A site stores no ports; derive its output ports from the mask (absolute)
|
||||
// and run the same input-edge scan (REQ-BLD-BELT-DRAG, REQ-MAT-INPUT-PORTS).
|
||||
@@ -825,7 +825,7 @@ void BuildingSystem::cancelDeconstruction(BuildingId id)
|
||||
// Resume operation: clear the flag and re-register belt/tunnel/splitter
|
||||
// tiles that were unregistered at enqueue (which re-pairs tunnels,
|
||||
// REQ-BLD-TUNNEL-PAIR). Deconstruction progress is discarded; no refund.
|
||||
if (Building* building = findBuildingMutable(id))
|
||||
if (Building* building = findBuilding(m_state, id))
|
||||
{
|
||||
building->queuedForDeconstruction = false;
|
||||
reregisterBeltTile(*building, it->splitterFilterA, it->splitterFilterB);
|
||||
@@ -838,12 +838,6 @@ void BuildingSystem::cancelDeconstruction(BuildingId id)
|
||||
}
|
||||
}
|
||||
|
||||
bool BuildingSystem::isQueuedForDeconstruction(BuildingId id) const
|
||||
{
|
||||
const Building* building = findBuilding(id);
|
||||
return building && building->queuedForDeconstruction;
|
||||
}
|
||||
|
||||
void BuildingSystem::tickBeltPull()
|
||||
{
|
||||
TRACE();
|
||||
@@ -941,7 +935,7 @@ bool BuildingSystem::tryDirectCoupleDeposit(BuildingId producerId,
|
||||
return false;
|
||||
}
|
||||
|
||||
Building* consumer = findBuildingMutable(*ownerId);
|
||||
Building* consumer = findBuilding(m_state, *ownerId);
|
||||
if (!consumer)
|
||||
{
|
||||
return false; // an unbuilt construction site, or not an operational building
|
||||
@@ -1263,41 +1257,6 @@ void BuildingSystem::forEachIncomingItem(
|
||||
// Queries
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const Building* BuildingSystem::findBuilding(BuildingId id) const
|
||||
{
|
||||
return ::findBuilding(m_state, id);
|
||||
}
|
||||
|
||||
Building* BuildingSystem::findBuildingMutable(BuildingId id)
|
||||
{
|
||||
return ::findBuilding(m_state, id);
|
||||
}
|
||||
|
||||
const ConstructionSite* BuildingSystem::findSite(BuildingId id) const
|
||||
{
|
||||
return ::findSite(m_state, id);
|
||||
}
|
||||
|
||||
std::vector<Building> BuildingSystem::getAllBuildings() const
|
||||
{
|
||||
return ::getAllBuildings(m_state);
|
||||
}
|
||||
|
||||
std::vector<ConstructionSite> BuildingSystem::getAllSites() const
|
||||
{
|
||||
return ::getAllSites(m_state);
|
||||
}
|
||||
|
||||
int BuildingSystem::getProductionBuildingCount() const
|
||||
{
|
||||
return ::getProductionBuildingCount(m_state);
|
||||
}
|
||||
|
||||
int BuildingSystem::getActiveProductionBuildingCount() const
|
||||
{
|
||||
return ::getActiveProductionBuildingCount(m_state);
|
||||
}
|
||||
|
||||
std::vector<const RecipeDef*>
|
||||
BuildingSystem::gatherCandidateRecipes(const Building& b) const
|
||||
{
|
||||
@@ -1471,11 +1430,6 @@ std::vector<BuildingSystem::BeltTileInfo> BuildingSystem::getAllBeltTiles() cons
|
||||
return result;
|
||||
}
|
||||
|
||||
bool BuildingSystem::isTileOccupied(QPoint tile) const
|
||||
{
|
||||
return ::isTileOccupied(m_state, tile);
|
||||
}
|
||||
|
||||
std::optional<BuildingId> BuildingSystem::findRotateInPlaceTarget(
|
||||
BuildingType type, QPoint anchor, Rotation rot) const
|
||||
{
|
||||
@@ -1591,17 +1545,6 @@ void BuildingSystem::rotateInPlace(BuildingId id, Rotation newRotation)
|
||||
}
|
||||
}
|
||||
|
||||
const Building* BuildingSystem::findNearestBuilding(QVector2D worldPos,
|
||||
BuildingType type) const
|
||||
{
|
||||
return ::findNearestBuilding(m_state, worldPos, type);
|
||||
}
|
||||
|
||||
bool BuildingSystem::deliverScrapToSalvageBay(BuildingId bayId)
|
||||
{
|
||||
return ::deliverScrapToSalvageBay(m_state, bayId);
|
||||
}
|
||||
|
||||
BuildingId BuildingSystem::placeImmediate(BuildingType type,
|
||||
const std::vector<std::string>& surfaceMask,
|
||||
QPoint anchor, Rotation rotation)
|
||||
|
||||
Reference in New Issue
Block a user