载入中...
搜索中...
未找到
eve::building::PlacementSystem类 参考

#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 PlacementSysteminst ()
 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.h19 行定义.

成员类型定义说明

◆ ChangeHook

using eve::building::PlacementSystem::ChangeHook = std::function<void(const BuildingChangeEvent &ev)>

在文件 PlacementSystem.h25 行定义.

◆ SnapFn

using eve::building::PlacementSystem::SnapFn = std::function<SnapResult(const PlacementWorld &world, float worldX, float worldY)>

在文件 PlacementSystem.h23 行定义.

◆ SurfaceFn

using eve::building::PlacementSystem::SurfaceFn = std::function<bool(const PlacementWorld &world, float x, float y, PlacementHit *hit)>

放置表面:把指针坐标(2D 场景为鼠标世界坐标;3D 场景由游戏自行做 射线/高度采样后传入平面坐标)换算成真实世界命中点。 引擎只提供接口 + 内置 "plane"(Y=常数平面),物理射线 / 高度场等 表面由游戏侧按接口实现。

在文件 PlacementSystem.h39 行定义.

◆ ValidateFn

using eve::building::PlacementSystem::ValidateFn = std::function<bool(const PlacementWorld &world, const PlacementQuery &q, std::string *reason)>

在文件 PlacementSystem.h21 行定义.

成员函数说明

◆ canPlace()

bool eve::building::PlacementSystem::canPlace ( PlacementWorld world,
const std::string &  buildingId,
int  cellX,
int  cellY,
float  rotationDeg = 0.f,
int  excludeInstanceId = 0,
std::string *  reason = nullptr 
)
static

◆ canPlaceElev()

bool eve::building::PlacementSystem::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

◆ clearBuildings()

void eve::building::PlacementSystem::clearBuildings ( PlacementWorld world)
static

◆ clearEvents()

void eve::building::PlacementSystem::clearEvents ( )
static

在文件 PlacementSystem.cpp233 行定义.

被这些函数引用 eve::building::Building::clearChangeEvents().

◆ effectiveFootprint()

void eve::building::PlacementSystem::effectiveFootprint ( const BuildingDefinition def,
float  rotationDeg,
int *  outW,
int *  outH 
)
static

◆ ensureBuiltins()

◆ events()

◆ foreachFootprintCell()

bool eve::building::PlacementSystem::foreachFootprintCell ( const BuildingDefinition def,
int  originCellX,
int  originCellY,
float  rotationDeg,
const std::function< bool(int cx, int cy)> &  fn 
)
static

◆ getPlaneSurfaceHeight()

float eve::building::PlacementSystem::getPlaneSurfaceHeight ( )
static

在文件 PlacementSystem.cpp130 行定义.

被这些函数引用 eve::building::Building::getPlaneSurfaceHeight().

◆ hasChangeHook()

bool eve::building::PlacementSystem::hasChangeHook ( const std::string &  name)
static

在文件 PlacementSystem.cpp95 行定义.

引用了 name.

◆ hasSnapRule()

bool eve::building::PlacementSystem::hasSnapRule ( const std::string &  name)
static

在文件 PlacementSystem.cpp83 行定义.

引用了 ensureBuiltins() , 以及 name.

被这些函数引用 eve::building::Building::hasSnapRule().

◆ hasSurface()

bool eve::building::PlacementSystem::hasSurface ( const std::string &  name)
static

在文件 PlacementSystem.cpp106 行定义.

引用了 ensureBuiltins() , 以及 name.

被这些函数引用 eve::building::Building::hasSurface().

◆ hasValidateRule()

bool eve::building::PlacementSystem::hasValidateRule ( const std::string &  name)
static

在文件 PlacementSystem.cpp71 行定义.

引用了 ensureBuiltins() , 以及 name.

被这些函数引用 eve::building::Building::hasValidateRule().

◆ inst()

PlacementSystem & eve::building::PlacementSystem::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.cpp29 行定义.

◆ moveBuilding()

◆ nextInstanceId()

int eve::building::PlacementSystem::nextInstanceId ( )
static

在文件 PlacementSystem.cpp224 行定义.

◆ normalizeRotation()

float eve::building::PlacementSystem::normalizeRotation ( const std::string &  buildingId,
float  rotationDeg 
)
static

规范化旋转角(cardinal → 0/90/180/270;none → 0)。

在文件 PlacementSystem.cpp286 行定义.

引用了 d, eve::building::BuildingRegistry::find() , 以及 eve::building::BuildingDefinition::rotationMode.

被这些函数引用 eve::building::Ghost::validate().

◆ placeAt()

◆ placeAtWorld()

int eve::building::PlacementSystem::placeAtWorld ( PlacementWorld world,
const std::string &  buildingId,
float  worldX,
float  worldY,
float  rotationDeg = 0.f 
)
static

先吸附再放置;free/自定义 snap 会保留吸附后的世界坐标。

在文件 PlacementSystem.cpp560 行定义.

引用了 eve::building::PlacementWorld::buildings(), id , 以及 s.

被这些函数引用 eve::building::PlacementWorld::placeAtWorld().

◆ placeAtWorld3D()

int eve::building::PlacementSystem::placeAtWorld3D ( PlacementWorld world,
const std::string &  buildingId,
float  worldX,
float  worldY,
float  worldZ,
float  rotationDeg = 0.f 
)
static

3D 版本:真实世界坐标 (wx, wy, wz),按平面轴吸附后放置。

在文件 PlacementSystem.cpp576 行定义.

引用了 eve::building::PlacementWorld::buildings(), id , 以及 s.

被这些函数引用 eve::building::PlacementWorld::placeAtWorld3D().

◆ placeGhost()

◆ pollEvents()

void eve::building::PlacementSystem::pollEvents ( std::vector< BuildingChangeEvent > &  out)
static

在文件 PlacementSystem.cpp228 行定义.

◆ pushEvent()

void eve::building::PlacementSystem::pushEvent ( BuildingChangeEvent  ev)
static

在文件 PlacementSystem.cpp226 行定义.

◆ registerChangeHook()

void eve::building::PlacementSystem::registerChangeHook ( const std::string &  name,
ChangeHook  fn 
)
static

在文件 PlacementSystem.cpp88 行定义.

引用了 fn , 以及 name.

◆ registerSnapRule()

void eve::building::PlacementSystem::registerSnapRule ( const std::string &  name,
SnapFn  fn 
)
static

在文件 PlacementSystem.cpp76 行定义.

引用了 fn , 以及 name.

被这些函数引用 ensureBuiltins().

◆ registerSurface()

void eve::building::PlacementSystem::registerSurface ( const std::string &  name,
SurfaceFn  fn 
)
static

在文件 PlacementSystem.cpp99 行定义.

引用了 fn , 以及 name.

被这些函数引用 ensureBuiltins().

◆ registerValidateRule()

void eve::building::PlacementSystem::registerValidateRule ( const std::string &  name,
ValidateFn  fn 
)
static

在文件 PlacementSystem.cpp62 行定义.

引用了 fn , 以及 name.

被这些函数引用 ensureBuiltins().

◆ removeBuilding()

◆ setPlaneSurfaceHeight()

void eve::building::PlacementSystem::setPlaneSurfaceHeight ( float  h)
static

内置 "plane" 表面的常量高度(默认 0)。

在文件 PlacementSystem.cpp128 行定义.

引用了 h.

被这些函数引用 eve::building::Building::setPlaneSurfaceHeight().

◆ snap()

SnapResult eve::building::PlacementSystem::snap ( const PlacementWorld world,
const std::string &  buildingId,
float  worldX,
float  worldY 
)
static

◆ snap3D()

SnapResult eve::building::PlacementSystem::snap3D ( const PlacementWorld world,
const std::string &  buildingId,
float  worldX,
float  worldY,
float  worldZ 
)
static

3D 版本:按世界平面轴把 (wx, wy, wz) 映射到网格平面坐标再吸附。

在文件 PlacementSystem.cpp271 行定义.

引用了 eve::building::PlacementWorld::getGrid(), eve::grid::GridConfig::plane, px, s, snap() , 以及 eve::grid::XZ.

被这些函数引用 eve::building::Ghost::setFromWorld3D().

◆ snapWithMode()

◆ surfaceHit()

bool eve::building::PlacementSystem::surfaceHit ( const PlacementWorld world,
const std::string &  name,
float  x,
float  y,
PlacementHit hit 
)
static

在文件 PlacementSystem.cpp111 行定义.

引用了 ensureBuiltins(), name, x , 以及 y.

被这些函数引用 eve::building::Ghost::setFromSurface().

◆ surfaceNames()

std::vector< std::string > eve::building::PlacementSystem::surfaceNames ( )
static

◆ unregisterChangeHook()

void eve::building::PlacementSystem::unregisterChangeHook ( const std::string &  name)
static

在文件 PlacementSystem.cpp93 行定义.

引用了 name.

◆ unregisterSnapRule()

void eve::building::PlacementSystem::unregisterSnapRule ( const std::string &  name)
static

在文件 PlacementSystem.cpp81 行定义.

引用了 name.

◆ unregisterSurface()

void eve::building::PlacementSystem::unregisterSurface ( const std::string &  name)
static

在文件 PlacementSystem.cpp104 行定义.

引用了 name.

◆ unregisterValidateRule()

void eve::building::PlacementSystem::unregisterValidateRule ( const std::string &  name)
static

在文件 PlacementSystem.cpp67 行定义.

引用了 name.


该类的文档由以下文件生成: