#include <PlacementSystem.h>
类 | |
| struct | PlacementHit |
Public 类型 | |
| using | ValidateFn = std::function< bool(const PlacementWorld &world, const PlacementQuery &q, std::string *reason)> |
| using | SnapFn = std::function< SnapResult(const PlacementWorld &world, float worldX, float worldY)> |
| using | ChangeHook = std::function< void(const BuildingChangeEvent &ev)> |
| using | SurfaceFn = std::function< bool(const PlacementWorld &world, float x, float y, PlacementHit *hit)> |
静态 Public 成员函数 | |
| static PlacementSystem & | inst () |
| Process singleton holding all PlacementSystem state. | |
| static void | registerValidateRule (const std::string &name, ValidateFn fn) |
| static void | unregisterValidateRule (const std::string &name) |
| static bool | hasValidateRule (const std::string &name) |
| static void | registerSnapRule (const std::string &name, SnapFn fn) |
| static void | unregisterSnapRule (const std::string &name) |
| static bool | hasSnapRule (const std::string &name) |
| static void | registerChangeHook (const std::string &name, ChangeHook fn) |
| static void | unregisterChangeHook (const std::string &name) |
| static bool | hasChangeHook (const std::string &name) |
| static void | registerSurface (const std::string &name, SurfaceFn fn) |
| static void | unregisterSurface (const std::string &name) |
| static bool | hasSurface (const std::string &name) |
| static bool | surfaceHit (const PlacementWorld &world, const std::string &name, float x, float y, PlacementHit *hit) |
| static std::vector< std::string > | surfaceNames () |
| static void | setPlaneSurfaceHeight (float h) |
| static float | getPlaneSurfaceHeight () |
| static void | ensureBuiltins () |
| 确保内置规则已注册(模块首次使用时自动调用)。 | |
| static SnapResult | snap (const PlacementWorld &world, const std::string &buildingId, float worldX, float worldY) |
| static SnapResult | snap3D (const PlacementWorld &world, const std::string &buildingId, float worldX, float worldY, float worldZ) |
| static SnapResult | snapWithMode (const PlacementWorld &world, const std::string &mode, float worldX, float worldY) |
| static float | normalizeRotation (const std::string &buildingId, float rotationDeg) |
| 规范化旋转角(cardinal → 0/90/180/270;none → 0)。 | |
| static void | effectiveFootprint (const BuildingDefinition &def, float rotationDeg, int *outW, int *outH) |
| 旋转后的占地宽高(cardinal 90/270 交换)。 | |
| static bool | foreachFootprintCell (const BuildingDefinition &def, int originCellX, int originCellY, float rotationDeg, const std::function< bool(int cx, int cy)> &fn) |
| 枚举占地格子(旋转后局部 → 世界格子)。返回 false 若定义未知。 | |
| static bool | canPlace (PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f, int excludeInstanceId=0, std::string *reason=nullptr) |
| static bool | canPlaceElev (PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float elevation, float rotationDeg=0.f, int excludeInstanceId=0, std::string *reason=nullptr) |
| static int | placeAt (PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f) |
| 成功返回 instanceId;失败返回 0。 | |
| static int | placeAtWorld (PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float rotationDeg=0.f) |
| 先吸附再放置;free/自定义 snap 会保留吸附后的世界坐标。 | |
| static int | placeAtWorld3D (PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float worldZ, float rotationDeg=0.f) |
| static int | placeGhost (PlacementWorld *world, Ghost *ghost) |
| static bool | removeBuilding (PlacementWorld *world, int instanceId) |
| static bool | moveBuilding (PlacementWorld *world, int instanceId, int cellX, int cellY, float rotationDeg=-1.f) |
| static void | clearBuildings (PlacementWorld *world) |
| static void | pushEvent (BuildingChangeEvent ev) |
| static void | pollEvents (std::vector< BuildingChangeEvent > &out) |
| static void | clearEvents () |
| static const std::vector< BuildingChangeEvent > & | events () |
| static int | nextInstanceId () |
详细描述
在文件 PlacementSystem.h 第 19 行定义.
成员类型定义说明
◆ ChangeHook
| using eve::building::PlacementSystem::ChangeHook = std::function<void(const BuildingChangeEvent &ev)> |
在文件 PlacementSystem.h 第 25 行定义.
◆ SnapFn
| using eve::building::PlacementSystem::SnapFn = std::function<SnapResult(const PlacementWorld &world, float worldX, float worldY)> |
在文件 PlacementSystem.h 第 23 行定义.
◆ SurfaceFn
| using eve::building::PlacementSystem::SurfaceFn = std::function<bool(const PlacementWorld &world, float x, float y, PlacementHit *hit)> |
放置表面:把指针坐标(2D 场景为鼠标世界坐标;3D 场景由游戏自行做 射线/高度采样后传入平面坐标)换算成真实世界命中点。 引擎只提供接口 + 内置 "plane"(Y=常数平面),物理射线 / 高度场等 表面由游戏侧按接口实现。
在文件 PlacementSystem.h 第 39 行定义.
◆ ValidateFn
| using eve::building::PlacementSystem::ValidateFn = std::function<bool(const PlacementWorld &world, const PlacementQuery &q, std::string *reason)> |
在文件 PlacementSystem.h 第 21 行定义.
成员函数说明
◆ canPlace()
|
static |
在文件 PlacementSystem.cpp 第 487 行定义.
被这些函数引用 eve::building::PlacementWorld::canPlace() , 以及 eve::building::PlacementWorld::canPlaceReason().
◆ canPlaceElev()
|
static |
带 elevation 的校验(校验语义仍按 2D 占用/地形,elevation 只进 query 上下文)。
在文件 PlacementSystem.cpp 第 463 行定义.
引用了 eve::building::PlacementQuery::buildingId, eve::building::PlacementWorld::cellToWorldPlane(), eve::building::PlacementQuery::cellX, eve::building::PlacementQuery::cellY, eve::building::PlacementQuery::elevation, eve::building::PlacementQuery::excludeInstanceId, eve::building::PlacementQuery::rotationDeg, eve::building::PlacementQuery::worldX , 以及 eve::building::PlacementQuery::worldY.
被这些函数引用 eve::building::Ghost::validate().
◆ clearBuildings()
|
static |
◆ clearEvents()
|
static |
在文件 PlacementSystem.cpp 第 233 行定义.
◆ effectiveFootprint()
|
static |
旋转后的占地宽高(cardinal 90/270 交换)。
在文件 PlacementSystem.cpp 第 300 行定义.
引用了 eve::building::BuildingDefinition::footprintH, eve::building::BuildingDefinition::footprintMask, eve::building::BuildingDefinition::footprintW, h, eve::grid::rotatedFootprintSize(), eve::building::BuildingDefinition::rotationMode , 以及 w.
◆ ensureBuiltins()
|
static |
确保内置规则已注册(模块首次使用时自动调用)。
在文件 PlacementSystem.cpp 第 136 行定义.
引用了 eve::building::PlacementQuery::buildingId, eve::building::PlacementWorld::cellToWorldPlane(), eve::building::SnapResult::cellX, eve::building::SnapResult::cellY, cx, cy, eve::building::BuildingRegistry::find(), eve::building::PlacementWorld::getGrid(), eve::building::PlacementWorld::getHeight(), eve::building::PlacementWorld::getWidth(), h, eve::grid::GridConfig::plane, registerSnapRule(), registerSurface(), registerValidateRule(), eve::grid::worldToCell(), eve::building::PlacementWorld::worldToCellX(), eve::building::PlacementWorld::worldToCellY(), eve::building::SnapResult::worldX, eve::building::PlacementSystem::PlacementHit::worldX, eve::building::SnapResult::worldY, eve::building::PlacementSystem::PlacementHit::worldY, eve::building::PlacementSystem::PlacementHit::worldZ, x, eve::grid::XZ , 以及 y.
被这些函数引用 hasSnapRule(), hasSurface(), hasValidateRule(), eve::building::Building::newGhost(), eve::building::Building::newSession(), eve::building::Building::newWorld(), eve::building::PlacementWorld::PlacementWorld(), eve::building::Building::registerBuildingsFromJson(), snap(), snapWithMode(), surfaceHit() , 以及 surfaceNames().
◆ events()
|
static |
在文件 PlacementSystem.cpp 第 235 行定义.
被这些函数引用 eve::building::Building::getChangeEventAction(), eve::building::Building::getChangeEventBuildingId(), eve::building::Building::getChangeEventCellX(), eve::building::Building::getChangeEventCellY(), eve::building::Building::getChangeEventCount(), eve::building::Building::getChangeEventInstanceId(), eve::building::Building::getChangeEventOtherCellX(), eve::building::Building::getChangeEventOtherCellY(), eve::building::Building::getChangeEventRotation() , 以及 eve::building::Building::getChangeEventWorldId().
◆ foreachFootprintCell()
|
static |
枚举占地格子(旋转后局部 → 世界格子)。返回 false 若定义未知。
在文件 PlacementSystem.cpp 第 316 行定义.
引用了 fn, eve::building::BuildingDefinition::footprintH, eve::building::BuildingDefinition::footprintMask, eve::building::BuildingDefinition::footprintW, eve::grid::foreachRotatedFootprint(), ok , 以及 eve::building::BuildingDefinition::rotationMode.
◆ getPlaneSurfaceHeight()
|
static |
在文件 PlacementSystem.cpp 第 130 行定义.
◆ hasChangeHook()
|
static |
在文件 PlacementSystem.cpp 第 95 行定义.
引用了 name.
◆ hasSnapRule()
|
static |
在文件 PlacementSystem.cpp 第 83 行定义.
引用了 ensureBuiltins() , 以及 name.
◆ hasSurface()
|
static |
在文件 PlacementSystem.cpp 第 106 行定义.
引用了 ensureBuiltins() , 以及 name.
◆ hasValidateRule()
|
static |
在文件 PlacementSystem.cpp 第 71 行定义.
引用了 ensureBuiltins() , 以及 name.
◆ inst()
|
static |
Process singleton holding all PlacementSystem state.
Rules / hooks / events / counters used to live in one function-local static per accessor, which made the state invisible, non-destructible and hard to reason about across hot-reload and tests. State now lives in this single instance's members; the static API below delegates to it.
在文件 PlacementSystem.cpp 第 29 行定义.
◆ moveBuilding()
|
static |
在文件 PlacementSystem.cpp 第 635 行定义.
引用了 eve::building::BuildingChangeEvent::action, eve::building::PlacedBuilding::buildingId, eve::building::BuildingChangeEvent::buildingId, eve::building::PlacementWorld::buildings(), eve::building::PlacementWorld::cellToWorldPlane(), eve::building::BuildingChangeEvent::cellX, eve::building::BuildingChangeEvent::cellY, eve::building::PlacedBuilding::channel, eve::building::BuildingChangeEvent::channel, eve::building::PlacedBuilding::elevation, eve::building::BuildingChangeEvent::elevation, eve::building::PlacementWorld::getId(), eve::building::BuildingChangeEvent::instanceId, eve::building::PlacedBuilding::originCellX, eve::building::PlacedBuilding::originCellY, eve::building::BuildingChangeEvent::otherCellX, eve::building::BuildingChangeEvent::otherCellY, px, eve::building::PlacedBuilding::rotationDeg, eve::building::BuildingChangeEvent::rotationDeg, eve::building::BuildingChangeEvent::worldId, eve::building::PlacedBuilding::worldX, eve::building::BuildingChangeEvent::worldX, eve::building::PlacedBuilding::worldY , 以及 eve::building::BuildingChangeEvent::worldY.
◆ nextInstanceId()
|
static |
在文件 PlacementSystem.cpp 第 224 行定义.
◆ normalizeRotation()
|
static |
规范化旋转角(cardinal → 0/90/180/270;none → 0)。
在文件 PlacementSystem.cpp 第 286 行定义.
引用了 d, eve::building::BuildingRegistry::find() , 以及 eve::building::BuildingDefinition::rotationMode.
被这些函数引用 eve::building::Ghost::validate().
◆ placeAt()
|
static |
成功返回 instanceId;失败返回 0。
在文件 PlacementSystem.cpp 第 520 行定义.
引用了 eve::building::BuildingChangeEvent::action, eve::building::PlacedBuilding::buildingId, eve::building::BuildingChangeEvent::buildingId, eve::building::PlacementWorld::buildings(), eve::building::PlacementWorld::cellToWorldPlane(), eve::building::BuildingChangeEvent::cellX, eve::building::BuildingChangeEvent::cellY, eve::building::BuildingDefinition::channel, eve::building::PlacedBuilding::channel, eve::building::BuildingChangeEvent::channel, eve::building::PlacedBuilding::elevation, eve::building::BuildingChangeEvent::elevation, eve::building::PlacementWorld::getId(), eve::building::PlacedBuilding::instanceId, eve::building::BuildingChangeEvent::instanceId, eve::building::PlacedBuilding::originCellX, eve::building::PlacedBuilding::originCellY, eve::building::PlacedBuilding::rotationDeg, eve::building::BuildingChangeEvent::rotationDeg, eve::building::BuildingDefinition::tags, eve::building::PlacedBuilding::tags, eve::building::BuildingChangeEvent::worldId, eve::building::PlacedBuilding::worldX, eve::building::BuildingChangeEvent::worldX, eve::building::PlacedBuilding::worldY , 以及 eve::building::BuildingChangeEvent::worldY.
◆ placeAtWorld()
|
static |
先吸附再放置;free/自定义 snap 会保留吸附后的世界坐标。
在文件 PlacementSystem.cpp 第 560 行定义.
引用了 eve::building::PlacementWorld::buildings(), id , 以及 s.
◆ placeAtWorld3D()
|
static |
3D 版本:真实世界坐标 (wx, wy, wz),按平面轴吸附后放置。
在文件 PlacementSystem.cpp 第 576 行定义.
引用了 eve::building::PlacementWorld::buildings(), id , 以及 s.
◆ placeGhost()
|
static |
在文件 PlacementSystem.cpp 第 593 行定义.
引用了 eve::building::PlacementWorld::buildings(), eve::building::Ghost::getBuildingId(), eve::building::Ghost::getCellX(), eve::building::Ghost::getCellY(), eve::building::Ghost::getElevation(), eve::building::Ghost::getRotationDeg(), eve::building::Ghost::getWorldX(), eve::building::Ghost::getWorldY(), id , 以及 eve::building::Ghost::validate().
◆ pollEvents()
|
static |
在文件 PlacementSystem.cpp 第 228 行定义.
◆ pushEvent()
|
static |
在文件 PlacementSystem.cpp 第 226 行定义.
◆ registerChangeHook()
|
static |
在文件 PlacementSystem.cpp 第 88 行定义.
◆ registerSnapRule()
|
static |
◆ registerSurface()
|
static |
◆ registerValidateRule()
|
static |
◆ removeBuilding()
|
static |
在文件 PlacementSystem.cpp 第 609 行定义.
引用了 eve::building::BuildingChangeEvent::action, eve::building::BuildingChangeEvent::buildingId, eve::building::PlacementWorld::buildings(), eve::building::BuildingChangeEvent::cellX, eve::building::BuildingChangeEvent::cellY, eve::building::BuildingChangeEvent::channel, eve::building::BuildingChangeEvent::elevation, eve::building::PlacementWorld::getId(), eve::building::BuildingChangeEvent::instanceId, eve::building::BuildingChangeEvent::rotationDeg, eve::building::BuildingChangeEvent::worldId, eve::building::BuildingChangeEvent::worldX , 以及 eve::building::BuildingChangeEvent::worldY.
◆ setPlaneSurfaceHeight()
|
static |
◆ snap()
|
static |
◆ snap3D()
|
static |
3D 版本:按世界平面轴把 (wx, wy, wz) 映射到网格平面坐标再吸附。
在文件 PlacementSystem.cpp 第 271 行定义.
引用了 eve::building::PlacementWorld::getGrid(), eve::grid::GridConfig::plane, px, s, snap() , 以及 eve::grid::XZ.
◆ snapWithMode()
|
static |
在文件 PlacementSystem.cpp 第 244 行定义.
引用了 eve::building::PlacementWorld::cellToWorldX(), eve::building::PlacementWorld::cellToWorldY(), eve::building::SnapResult::cellX, eve::building::SnapResult::cellY, ensureBuiltins(), eve::building::PlacementWorld::worldToCellX(), eve::building::PlacementWorld::worldToCellY(), eve::building::SnapResult::worldX , 以及 eve::building::SnapResult::worldY.
被这些函数引用 snap().
◆ surfaceHit()
|
static |
在文件 PlacementSystem.cpp 第 111 行定义.
引用了 ensureBuiltins(), name, x , 以及 y.
◆ surfaceNames()
|
static |
在文件 PlacementSystem.cpp 第 120 行定义.
引用了 ensureBuiltins().
被这些函数引用 eve::building::Building::getSurfaceCount() , 以及 eve::building::Building::getSurfaceName().
◆ unregisterChangeHook()
|
static |
在文件 PlacementSystem.cpp 第 93 行定义.
引用了 name.
◆ unregisterSnapRule()
|
static |
在文件 PlacementSystem.cpp 第 81 行定义.
引用了 name.
◆ unregisterSurface()
|
static |
在文件 PlacementSystem.cpp 第 104 行定义.
引用了 name.
◆ unregisterValidateRule()
|
static |
在文件 PlacementSystem.cpp 第 67 行定义.
引用了 name.
该类的文档由以下文件生成:
- src/modules/building/PlacementSystem.h
- src/modules/building/PlacementSystem.cpp