rename EntityId to BuildingId
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
#include "BeltSystem.h"
|
||||
#include "Building.h"
|
||||
#include "BuildingType.h"
|
||||
#include "EntityId.h"
|
||||
#include "BuildingId.h"
|
||||
#include "GameConfig.h"
|
||||
#include "Rotation.h"
|
||||
#include "ModulesConfig.h"
|
||||
@@ -32,7 +32,7 @@ class BuildingSystem
|
||||
public:
|
||||
BuildingSystem(const GameConfig& config,
|
||||
BeltSystem& belts,
|
||||
std::function<EntityId()> allocateId,
|
||||
std::function<BuildingId()> allocateBuildingId,
|
||||
std::function<void(int)> addBuildingBlocks,
|
||||
std::function<void(const std::string&, QVector2D,
|
||||
const std::optional<ShipLayoutConfig>&)> spawnShip,
|
||||
@@ -41,21 +41,21 @@ public:
|
||||
// -- Placement / demolish ------------------------------------------------
|
||||
// Returns the new entity id. Belt and Splitter register with BeltSystem
|
||||
// directly; other types enter the construction queue.
|
||||
EntityId place(BuildingType type, QPoint anchor, Rotation rotation,
|
||||
BuildingId place(BuildingType type, QPoint anchor, Rotation rotation,
|
||||
Tick currentTick);
|
||||
|
||||
// Remove a building or construction site by id. Returns the refund in
|
||||
// building blocks (floor(cost * refundPercentage / 100)). Returns 0 for
|
||||
// unknown ids.
|
||||
int demolish(EntityId id);
|
||||
int demolish(BuildingId id);
|
||||
|
||||
// Set the recipe (or schematic id for shipyard) on a building or queued
|
||||
// construction site. Clears both buffers on an operational building.
|
||||
void setRecipe(EntityId id, const std::string& recipeId);
|
||||
void setRecipe(BuildingId id, const std::string& recipeId);
|
||||
|
||||
// Set the module layout for a shipyard. Cancels in-progress production
|
||||
// (materials discarded) and reinitializes input buffers (REQ-BLD-SHIPYARD).
|
||||
void setShipLayout(EntityId id, const ShipLayoutConfig& layout);
|
||||
void setShipLayout(BuildingId id, const ShipLayoutConfig& layout);
|
||||
|
||||
// -- Tick hooks (called from Simulation::tick in the documented order) ---
|
||||
void tickConstruction(Tick currentTick);
|
||||
@@ -67,15 +67,15 @@ public:
|
||||
// -- Queries -------------------------------------------------------------
|
||||
struct BeltTileInfo
|
||||
{
|
||||
EntityId id;
|
||||
BuildingId buildingId;
|
||||
QPoint tile;
|
||||
BuildingType type; // Belt or Splitter
|
||||
Rotation directionA; // Belt: its direction; Splitter: first output
|
||||
Rotation directionB; // Splitter: second output; Belt: same as directionA
|
||||
};
|
||||
|
||||
const Building* findBuilding(EntityId id) const;
|
||||
const ConstructionSite* findSite(EntityId id) const;
|
||||
const Building* findBuilding(BuildingId id) const;
|
||||
const ConstructionSite* findSite(BuildingId id) const;
|
||||
std::vector<Building> allBuildings() const;
|
||||
std::vector<ConstructionSite> allSites() const;
|
||||
std::vector<BeltTileInfo> allBeltTiles() const;
|
||||
@@ -84,36 +84,36 @@ public:
|
||||
// Returns the entity id of the building or construction site whose footprint
|
||||
// exactly coincides with the ghost (type, anchor, rot) and is of the same
|
||||
// building type. Returns nullopt otherwise.
|
||||
std::optional<EntityId> findRotateInPlaceTarget(BuildingType type,
|
||||
std::optional<BuildingId> findRotateInPlaceTarget(BuildingType type,
|
||||
QPoint anchor,
|
||||
Rotation rot) const;
|
||||
|
||||
// Rotate an existing building or construction site to newRotation in place.
|
||||
// For belt-type operational buildings, re-registers with BeltSystem (items
|
||||
// currently on the tile are discarded by BeltSystem::removeTile).
|
||||
void rotateInPlace(EntityId id, Rotation newRotation);
|
||||
void rotateInPlace(BuildingId id, Rotation newRotation);
|
||||
|
||||
// Find nearest operational building of the given type; nullptr if none.
|
||||
const Building* findNearestBuilding(QVector2D worldPos, BuildingType type) const;
|
||||
|
||||
// Register / unregister tile occupancy for ECS station entities.
|
||||
void registerTileOccupancy(const std::vector<QPoint>& cells, EntityId ownerPlaceholder);
|
||||
void registerTileOccupancy(const std::vector<QPoint>& cells, BuildingId ownerPlaceholder);
|
||||
void unregisterTileOccupancy(const std::vector<QPoint>& cells);
|
||||
|
||||
// Place one "scrap" item into a SalvageBay's output buffer.
|
||||
// Returns false if bay not found, wrong type, or output buffer is full.
|
||||
bool deliverScrapToSalvageBay(EntityId bayId);
|
||||
bool deliverScrapToSalvageBay(BuildingId bayId);
|
||||
|
||||
// Bypass the construction queue and create a fully-operational Building
|
||||
// immediately. Used for pre-placed structures (HQ, defence stations).
|
||||
// surfaceMask comes from the relevant config struct.
|
||||
EntityId placeImmediate(BuildingType type,
|
||||
BuildingId placeImmediate(BuildingType type,
|
||||
const std::vector<std::string>& surfaceMask,
|
||||
QPoint anchor, Rotation rotation);
|
||||
|
||||
// Remove an operational building by id without refund (used for deaths).
|
||||
// Returns true if found and removed.
|
||||
bool removeBuilding(EntityId id);
|
||||
bool removeBuilding(BuildingId id);
|
||||
|
||||
// Mutable iteration over all operational buildings.
|
||||
void forEachBuilding(std::function<void(Building&)> fn);
|
||||
@@ -130,7 +130,7 @@ private:
|
||||
|
||||
const GameConfig& m_config;
|
||||
BeltSystem& m_belts;
|
||||
std::function<EntityId()> m_allocateId;
|
||||
std::function<BuildingId()> m_allocateBuildingId;
|
||||
std::function<void(int)> m_addBuildingBlocks;
|
||||
std::function<void(const std::string&, QVector2D,
|
||||
const std::optional<ShipLayoutConfig>&)> m_spawnShip;
|
||||
@@ -140,5 +140,5 @@ private:
|
||||
std::deque<ConstructionSite> m_constructionQueue;
|
||||
|
||||
// Maps every occupied body-cell coordinate to the entity that owns it.
|
||||
std::map<std::pair<int, int>, EntityId> m_tileOccupancy;
|
||||
std::map<std::pair<int, int>, BuildingId> m_tileOccupancy;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user