depend on factory data instead of BuildingSystem in the AI path
This commit is contained in:
51
src/lib/sim/FactoryQueries.h
Normal file
51
src/lib/sim/FactoryQueries.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <QPoint>
|
||||
#include <QVector2D>
|
||||
|
||||
#include "Building.h"
|
||||
#include "BuildingId.h"
|
||||
#include "BuildingType.h"
|
||||
#include "FactoryState.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.
|
||||
|
||||
// The building with the given id, or nullptr when no building has it. Construction
|
||||
// sites are not buildings yet — use findSite for those.
|
||||
const Building* findBuilding(const FactoryState& state, BuildingId id);
|
||||
Building* findBuilding(FactoryState& state, BuildingId id);
|
||||
|
||||
// The queued construction site with the given id, or nullptr.
|
||||
const ConstructionSite* findSite(const FactoryState& state, BuildingId id);
|
||||
|
||||
std::vector<Building> getAllBuildings(const FactoryState& state);
|
||||
std::vector<ConstructionSite> getAllSites(const FactoryState& state);
|
||||
|
||||
// REQ-UI-DEBUG-OVERLAY "Max Factory Production": count of completed
|
||||
// (operational) Miner/Smelter/Assembler/ReprocessingPlant/Shipyard buildings.
|
||||
int getProductionBuildingCount(const FactoryState& state);
|
||||
|
||||
// REQ-UI-DEBUG-OVERLAY "Current Factory Production": subset of the above that
|
||||
// currently has an active production cycle.
|
||||
int getActiveProductionBuildingCount(const FactoryState& state);
|
||||
|
||||
bool isTileOccupied(const FactoryState& state, QPoint tile);
|
||||
|
||||
// The nearest building of the given type to a world position, or nullptr when
|
||||
// none exists. Distance is measured to the building's footprint centre.
|
||||
const Building* findNearestBuilding(const FactoryState& state, QVector2D worldPos,
|
||||
BuildingType type);
|
||||
|
||||
// Hands one scrap to a Salvage Bay's output buffer (REQ-BLD-SALVAGE-BAY). Fails
|
||||
// if the id is not a Salvage Bay, it is queued for deconstruction
|
||||
// (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);
|
||||
Reference in New Issue
Block a user