载入中...
搜索中...
未找到
PlacementWorld.cpp
浏览该文件的文档.
332int PlacementWorld::getOccupantInChannel(const std::string &channel, int cellX, int cellY) const {
381bool PlacementWorld::isCellEmptyInChannel(const std::string &channel, int cellX, int cellY) const {
692std::string PlacementWorld::canPlaceEdgeReason(const std::string &buildingId, int cellX, int cellY,
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:19
Pure cell/world projection helpers for GridConfig.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
static int placeAt(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
成功返回 instanceId;失败返回 0。
Definition PlacementSystem.cpp:2247
static int placeFree(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float elevation=0.f, float rotationDeg=0.f)
Compatibility-only id projection; prefer placeFreeResult in C++.
Definition PlacementSystem.cpp:1475
static int placeCorner(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY)
Compatibility-only id projection; prefer placeCornerResult in C++.
Definition PlacementSystem.cpp:1280
static bool containsFreePoint(const PlacedBuilding &placed, float worldX, float worldY)
Test a world-plane point against a committed circular or oriented-box footprint.
Definition PlacementSystem.cpp:1339
static int placeAtWorld3D(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float worldZ, float rotationDeg=0.f)
Definition PlacementSystem.cpp:2311
static int removeBuildingCascade(PlacementWorld *world, int instanceId)
Compatibility-only count projection; prefer removeBuildingCascadeResult in C++.
Definition PlacementSystem.cpp:2783
static void clearBuildings(PlacementWorld *world)
Definition PlacementSystem.cpp:3354
static std::string edgeVariant(const PlacementWorld &world, int instanceId)
Stable visual topology class: isolated/end/straight/corner/tee/cross.
Definition PlacementSystem.cpp:1540
static bool canPlaceFree(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, int excludeInstanceId=0, std::string *reason=nullptr, int level=std::numeric_limits< int >::min(), float rotationDeg=0.f)
Validate an exact free-domain world-plane anchor and circular or oriented-box footprint.
Definition PlacementSystem.cpp:1286
static bool removeBuilding(PlacementWorld *world, int instanceId)
Definition PlacementSystem.cpp:2710
static bool canPlaceCorner(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY, int excludeInstanceId=0, std::string *reason=nullptr, int level=std::numeric_limits< int >::min())
Validate a corner-domain placement at one canonical grid vertex.
Definition PlacementSystem.cpp:1187
static bool moveBuilding(PlacementWorld *world, int instanceId, int cellX, int cellY, float rotationDeg=-1.f)
Compatibility projection of moveBuildingResult; prefer the Result API in C++.
Definition PlacementSystem.cpp:2704
static int placeAtWorld(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float rotationDeg=0.f)
先吸附再放置;free/自定义 snap 会保留吸附后的世界坐标。
Definition PlacementSystem.cpp:2295
static uint8_t edgeConnectionMask(const PlacementWorld &world, int instanceId)
Compute compatible neighbouring edge topology.
Definition PlacementSystem.cpp:1482
static int placeGhost(PlacementWorld *world, Ghost *ghost)
Definition PlacementSystem.cpp:2328
static int placeEdge(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, const std::string &direction)
Place an edge-domain definition, returning the new instance id or zero.
Definition PlacementSystem.cpp:1133
static eve::Result< EdgeAddress > canonicalEdge(int cellX, int cellY, const std::string &direction)
Normalize a cell-relative cardinal direction to a unique edge address.
Definition PlacementSystem.cpp:1061
static bool canPlace(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f, int excludeInstanceId=0, std::string *reason=nullptr)
Definition PlacementSystem.cpp:1054
static bool canPlaceEdge(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, const std::string &direction, int excludeInstanceId=0, std::string *reason=nullptr, int level=std::numeric_limits< int >::min())
Validate an edge-domain placement without mutating the world.
Definition PlacementSystem.cpp:1084
float getBuildingSurfaceNormalZ(int instanceId) const
Z component of the unit surface normal captured at placement time.
Definition PlacementWorld.cpp:581
bool isEdgeEmpty(const std::string &channel, int cellX, int cellY, const std::string &direction) const
Return whether an edge is unoccupied in the requested channel.
Definition PlacementWorld.cpp:497
int getBuildingSupportCount(int instanceId) const
Number of direct structural supports used by an instance.
Definition PlacementWorld.cpp:440
std::string canPlaceReason(const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
Can place reason.
Definition PlacementWorld.cpp:626
std::string canPlaceEdgeReason(const std::string &buildingId, int cellX, int cellY, const std::string &direction)
Stable rejection token for edge placement.
Definition PlacementWorld.cpp:692
PlacementWorld(int width, int height, float cellSize=32.f)
创建 width×height 的格子世界,cellSize 为像素/格。
Definition PlacementWorld.cpp:17
int placeFree(const std::string &buildingId, float worldX, float worldY, float elevation=0.f, float rotationDeg=0.f)
Compatibility-only script projection of exact free placement.
Definition PlacementWorld.cpp:715
std::string getBuildingProp(int instanceId, const std::string &key, const std::string &fallback={}) const
Returns the building prop.
Definition PlacementWorld.cpp:596
bool canPlaceEdge(const std::string &buildingId, int cellX, int cellY, const std::string &direction)
Validate edge placement without mutation.
Definition PlacementWorld.cpp:687
float getBuildingWorldY(int instanceId) const
Returns the building world y.
Definition PlacementWorld.cpp:411
int placeCorner(const std::string &buildingId, int vertexX, int vertexY)
Compatibility-only script projection of canonical corner placement.
Definition PlacementWorld.cpp:699
int getBuildingCellY(int instanceId) const
Returns the building cell y.
Definition PlacementWorld.cpp:401
float getBuildingSurfaceNormalX(int instanceId) const
X component of the unit surface normal captured at placement time.
Definition PlacementWorld.cpp:571
int getEdgeConnectionMask(int instanceId) const
Six-bit local connection mask for an edge object's compatible neighbours.
Definition PlacementWorld.cpp:553
int getFreeOccupantAtLevel(const std::string &channel, float worldX, float worldY, int level) const
Query a free-domain footprint at an explicit floor.
Definition PlacementWorld.cpp:538
std::unordered_map< std::string, std::vector< int > > ChannelMap
Definition PlacementWorld.h:34
void setGridFromLayer(map::TileLayer *layer)
Sets the grid from layer.
Definition PlacementWorld.cpp:92
std::unique_ptr< PlacementWorld > cloneState() const
Clone complete logical state into an independently owned world candidate.
Definition PlacementWorld.cpp:741
float getBuildingWorldX(int instanceId) const
Returns the building world x.
Definition PlacementWorld.cpp:406
std::string canPlaceFreeReason(const std::string &buildingId, float worldX, float worldY)
Can place free reason.
Definition PlacementWorld.cpp:724
bool moveBuilding(int instanceId, int cellX, int cellY, float rotationDeg=-1.f)
Moves building.
Definition PlacementWorld.cpp:735
int getOccupantAtLevel(const std::string &channel, int cellX, int cellY, int level) const
Query one channel at an explicit discrete floor.
Definition PlacementWorld.cpp:336
int getBuildingLevel(int instanceId) const
Return an instance's authoritative discrete floor.
Definition PlacementWorld.cpp:435
float getBuildingElevation(int instanceId) const
Returns the building elevation.
Definition PlacementWorld.cpp:430
bool isCellEmptyInChannel(const std::string &channel, int cellX, int cellY) const
已放置建筑实例查询。
Definition PlacementWorld.cpp:381
int removeBuildingCascade(int instanceId)
Compatibility-only script projection of the canonical Result removal API.
Definition PlacementWorld.cpp:777
int getBuildingSupportAt(int instanceId, int index) const
Direct structural support id by stable footprint order, or zero.
Definition PlacementWorld.cpp:445
int getBuildingCellX(int instanceId) const
Returns the building cell x.
Definition PlacementWorld.cpp:396
float cellToWorld3DX(int cellX, int cellY, float elevation) const
Cell to world 3 dx.
Definition PlacementWorld.cpp:165
bool buildingHasTag(int instanceId, const std::string &tag) const
Building has tag.
Definition PlacementWorld.cpp:609
int placeAt(const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
Place at.
Definition PlacementWorld.cpp:633
int placeEdge(const std::string &buildingId, int cellX, int cellY, const std::string &direction)
Place an edge definition on a north/east/south/west edge; returns instance id or 0.
Definition PlacementWorld.cpp:682
void setFloorHeight(float height)
Set positive height between discrete floors. Invalid values are ignored.
Definition PlacementWorld.cpp:278
std::vector< EdgeCurveGroupId > edgeCurveGroupIds() const
Return an owning ascending list of all curve-group identities.
Definition PlacementWorld.cpp:672
void setExtra(const std::string &key, const std::string &value)
世界级额外属性(键值)。
Definition PlacementWorld.cpp:51
int getAnyCornerOccupantAtLevel(int vertexX, int vertexY, int level) const
Query the first corner occupant across channels at an explicit floor.
Definition PlacementWorld.cpp:518
void setTerrain(int cellX, int cellY, int semantic)
Sets the terrain.
Definition PlacementWorld.cpp:209
float getBuildingRotation(int instanceId) const
Returns the building rotation.
Definition PlacementWorld.cpp:591
int64_t getBuildingSurfaceRevision(int instanceId) const
Surface provider revision captured when this instance was placed.
Definition PlacementWorld.cpp:566
int worldToCell3DX(float worldX, float worldY, float worldZ) const
World to cell 3 dx.
Definition PlacementWorld.cpp:190
int getEdgeOccupant(const std::string &channel, int cellX, int cellY, const std::string &direction) const
Return the occupant of a canonicalized north/east/south/west cell edge.
Definition PlacementWorld.cpp:464
bool canPlaceFree(const std::string &buildingId, float worldX, float worldY)
Can place free.
Definition PlacementWorld.cpp:720
int placeAtWorld3D(const std::string &buildingId, float worldX, float worldY, float worldZ, float rotationDeg=0.f)
Place at world 3 d.
Definition PlacementWorld.cpp:643
int getEdgeOccupantAtLevel(const std::string &channel, int cellX, int cellY, const std::string &direction, int level) const
Query a canonical edge at an explicit discrete floor.
Definition PlacementWorld.cpp:469
bool canPlace(const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
便捷操作(转发 PlacementSystem):放置 / 移除 / 移动。
Definition PlacementWorld.cpp:621
void swapState(PlacementWorld &candidate) noexcept
Atomically exchange complete logical state with a prepared candidate.
Definition PlacementWorld.cpp:781
std::string getEdgeVariant(int instanceId) const
Stable topology variant name for an edge instance.
Definition PlacementWorld.cpp:557
void cellToWorldPlane(int cellX, int cellY, float &px, float &py) const
Cell to world plane.
Definition PlacementWorld.cpp:146
eve::Result< EdgeCurveGroup > edgeCurveGroupForInstance(int instanceId) const
Return the owning curve-group snapshot linked by an edge instance.
Definition PlacementWorld.cpp:662
int getCornerOccupantAtLevel(const std::string &channel, int vertexX, int vertexY, int level) const
Query a corner-domain occupant at an explicit floor.
Definition PlacementWorld.cpp:507
void setBuildingProp(int instanceId, const std::string &key, const std::string &value)
Sets the building prop.
Definition PlacementWorld.cpp:602
std::string getBuildingId(int instanceId) const
Returns the building id.
Definition PlacementWorld.cpp:391
eve::Result< EdgeCurveGroup > edgeCurveGroup(EdgeCurveGroupId id) const
Return an owning curve-group snapshot.
Definition PlacementWorld.cpp:652
std::string getExtra(const std::string &key, const std::string &fallback={}) const
Returns the extra.
Definition PlacementWorld.cpp:55
int worldToCell3DY(float worldX, float worldY, float worldZ) const
World to cell 3 dy.
Definition PlacementWorld.cpp:196
void setStagger(const std::string &axis, const std::string &index)
Sets the stagger.
Definition PlacementWorld.cpp:85
int placeAtWorld(const std::string &buildingId, float worldX, float worldY, float rotationDeg=0.f)
Place at world.
Definition PlacementWorld.cpp:638
int getCornerOccupant(const std::string &channel, int vertexX, int vertexY) const
Query a corner-domain occupant at the active floor.
Definition PlacementWorld.cpp:502
int getAnyOccupant(int cellX, int cellY) const
Returns the any occupant.
Definition PlacementWorld.cpp:354
void worldToCell3D(float worldX, float worldY, float worldZ, int &cellX, int &cellY) const
World to cell 3 d.
Definition PlacementWorld.cpp:183
std::string canPlaceCornerReason(const std::string &buildingId, int vertexX, int vertexY)
Stable corner placement rejection token.
Definition PlacementWorld.cpp:707
std::string canRemoveBuildingReason(int instanceId) const
Stable rejection token for ordinary removal (support_in_use when depended on).
Definition PlacementWorld.cpp:772
float cellToWorld3DY(int cellX, int cellY, float elevation) const
Cell to world 3 dy.
Definition PlacementWorld.cpp:171
int getAnyOccupantAtLevel(int cellX, int cellY, int level) const
Query the first occupant across channels at an explicit floor.
Definition PlacementWorld.cpp:358
int getFreeOccupant(const std::string &channel, float worldX, float worldY) const
Return the first free-domain object whose circular footprint contains the point.
Definition PlacementWorld.cpp:533
std::string getBuildingSurfaceId(int instanceId) const
Surface provider identity captured when this instance was placed.
Definition PlacementWorld.cpp:561
std::string getBuildingChannel(int instanceId) const
Returns the building channel.
Definition PlacementWorld.cpp:586
void setTerrainGidMapJson(const std::string &json)
Sets the terrain gid map json.
Definition PlacementWorld.cpp:253
float getBuildingWorldZ(int instanceId) const
Returns the building world z.
Definition PlacementWorld.cpp:421
int getOccupantInChannel(const std::string &channel, int cellX, int cellY) const
Returns the occupant in channel.
Definition PlacementWorld.cpp:332
bool canPlaceCorner(const std::string &buildingId, int vertexX, int vertexY)
Validate corner placement without mutation.
Definition PlacementWorld.cpp:703
float getBuildingSurfaceNormalY(int instanceId) const
Y component of the unit surface normal captured at placement time.
Definition PlacementWorld.cpp:576
float cellToWorld3DZ(int cellX, int cellY, float elevation) const
Cell to world 3 dz.
Definition PlacementWorld.cpp:177
std::vector< int > & channelOccupancy(const std::string &channel)
Channel occupancy.
Definition PlacementWorld.cpp:311
void cellToWorld3D(int cellX, int cellY, float elevation, float &worldX, float &worldY, float &worldZ) const
Cell to world 3 d.
Definition PlacementWorld.cpp:150
bool isCornerEmpty(const std::string &channel, int vertexX, int vertexY) const
Return whether a corner-domain address is empty in one channel.
Definition PlacementWorld.cpp:529
int getBuildingDependentCount(int instanceId) const
Number of instances that directly depend on this instance.
Definition PlacementWorld.cpp:453
ECS tile layer entity. Script mutates tile GIDs / tileset / draw; TileRenderSystem batch-draws atlas ...
Definition TileLayer.h:32
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:7
@ Horizontal
void worldToCell(const GridConfig &cfg, float px, float py, int &cx, int &cy, int mapW, int mapH)
Maps planar coordinates to the nearest cell. Staggered/hex layouts use a bounded nearest-neighbor sea...
Definition GridProjection.cpp:69
@ Hexagon
@ Isometric
@ Rectangle
@ Staggered
void cellToWorld(const GridConfig &cfg, int cx, int cy, float &px, float &py)
Maps a cell to planar coordinates (px, py). On XY plane these are world (x, y); on XZ plane they are ...
Definition GridProjection.cpp:30
@ Hexagonal
@ Orthogonal
@ Isometric
@ Staggered
@ NotFound
Strong world-local identity of one authoritative edge-curve group.
Definition BuildingTypes.h:48
int level
Authoritative discrete floor coordinate used by occupancy and topology.
Definition BuildingTypes.h:206
Grid shape, cell metrics, origin, and placement plane. Pure data; use GridProjection helpers for worl...
Definition GridConfig.h:34
static const char * layoutName(GridLayout l)
Stable string name for a layout enum value.
Definition GridConfig.cpp:5
static const char * planeName(GridPlane p)
Stable string name for a plane enum value.
Definition GridConfig.cpp:29
static GridPlane planeFromName(const std::string &name)
Parse a plane name; unknown names fall back to XY.
Definition GridConfig.cpp:33
static GridLayout layoutFromName(const std::string &name)
Parse a layout name; unknown names fall back to Rectangle.
Definition GridConfig.cpp:21