载入中...
搜索中...
未找到
PlacementWorld.cpp
浏览该文件的文档.
335int PlacementWorld::getOccupantInChannel(const std::string &channel, int cellX, int cellY) const {
384bool PlacementWorld::isCellEmptyInChannel(const std::string &channel, int cellX, int cellY) const {
695std::string PlacementWorld::canPlaceEdgeReason(const std::string &buildingId, int cellX, int cellY,
std::map< std::string, std::vector< Key >, std::less<> > channels
Definition AnimCurveLibrary.cpp:21
Pure cell/world projection helpers for GridConfig.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static int placeAt(PlacementWorld *world, const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
成功返回 instanceId;失败返回 0。
Definition PlacementMutation.cpp:69
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 PlacementDomains.cpp:416
static int placeCorner(PlacementWorld *world, const std::string &buildingId, int vertexX, int vertexY)
Compatibility-only id projection; prefer placeCornerResult in C++.
Definition PlacementDomains.cpp:235
static bool containsFreePoint(const PlacedBuilding &placed, float worldX, float worldY)
Test a world-plane point against a committed circular or oriented-box footprint.
Definition PlacementDomains.cpp:297
static int placeAtWorld3D(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float worldZ, float rotationDeg=0.f)
Definition PlacementMutation.cpp:133
static int removeBuildingCascade(PlacementWorld *world, int instanceId)
Compatibility-only count projection; prefer removeBuildingCascadeResult in C++.
Definition PlacementStructure.cpp:138
static void clearBuildings(PlacementWorld *world)
Definition PlacementMove.cpp:495
static std::string edgeVariant(const PlacementWorld &world, int instanceId)
Stable visual topology class: isolated/end/straight/corner/tee/cross.
Definition PlacementDomains.cpp:477
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 PlacementDomains.cpp:240
static bool removeBuilding(PlacementWorld *world, int instanceId)
Definition PlacementStructure.cpp:67
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 PlacementDomains.cpp:148
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 PlacementStructure.cpp:62
static int placeAtWorld(PlacementWorld *world, const std::string &buildingId, float worldX, float worldY, float rotationDeg=0.f)
先吸附再放置;free/自定义 snap 会保留吸附后的世界坐标。
Definition PlacementMutation.cpp:117
static uint8_t edgeConnectionMask(const PlacementWorld &world, int instanceId)
Compute compatible neighbouring edge topology.
Definition PlacementDomains.cpp:422
static int placeGhost(PlacementWorld *world, Ghost *ghost)
Definition PlacementMutation.cpp:149
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 PlacementDomains.cpp:95
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 PlacementDomains.cpp:20
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 PlacementValidation.cpp:309
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 PlacementDomains.cpp:42
float getBuildingSurfaceNormalZ(int instanceId) const
Z component of the unit surface normal captured at placement time.
Definition PlacementWorld.cpp:584
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:500
int getBuildingSupportCount(int instanceId) const
Number of direct structural supports used by an instance.
Definition PlacementWorld.cpp:443
std::string canPlaceReason(const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
Can place reason.
Definition PlacementWorld.cpp:629
std::string canPlaceEdgeReason(const std::string &buildingId, int cellX, int cellY, const std::string &direction)
Stable rejection token for edge placement.
Definition PlacementWorld.cpp:695
PlacementWorld(int width, int height, float cellSize=32.f)
创建 width×height 的格子世界,cellSize 为像素/格。
Definition PlacementWorld.cpp:18
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:718
std::string getBuildingProp(int instanceId, const std::string &key, const std::string &fallback={}) const
Returns the building prop.
Definition PlacementWorld.cpp:599
bool canPlaceEdge(const std::string &buildingId, int cellX, int cellY, const std::string &direction)
Validate edge placement without mutation.
Definition PlacementWorld.cpp:690
float getBuildingWorldY(int instanceId) const
Returns the building world y.
Definition PlacementWorld.cpp:414
int placeCorner(const std::string &buildingId, int vertexX, int vertexY)
Compatibility-only script projection of canonical corner placement.
Definition PlacementWorld.cpp:702
int getBuildingCellY(int instanceId) const
Returns the building cell y.
Definition PlacementWorld.cpp:404
float getBuildingSurfaceNormalX(int instanceId) const
X component of the unit surface normal captured at placement time.
Definition PlacementWorld.cpp:574
int getEdgeConnectionMask(int instanceId) const
Six-bit local connection mask for an edge object's compatible neighbours.
Definition PlacementWorld.cpp:556
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:541
std::unordered_map< std::string, std::vector< int > > ChannelMap
Definition PlacementWorld.h:37
void setGridFromLayer(map::TileLayer *layer)
Sets the grid from layer.
Definition PlacementWorld.cpp:95
std::unique_ptr< PlacementWorld > cloneState() const
Clone complete logical state into an independently owned world candidate.
Definition PlacementWorld.cpp:744
float getBuildingWorldX(int instanceId) const
Returns the building world x.
Definition PlacementWorld.cpp:409
std::string canPlaceFreeReason(const std::string &buildingId, float worldX, float worldY)
Can place free reason.
Definition PlacementWorld.cpp:727
bool moveBuilding(int instanceId, int cellX, int cellY, float rotationDeg=-1.f)
Moves building.
Definition PlacementWorld.cpp:738
int getOccupantAtLevel(const std::string &channel, int cellX, int cellY, int level) const
Query one channel at an explicit discrete floor.
Definition PlacementWorld.cpp:339
int getBuildingLevel(int instanceId) const
Return an instance's authoritative discrete floor.
Definition PlacementWorld.cpp:438
float getBuildingElevation(int instanceId) const
Returns the building elevation.
Definition PlacementWorld.cpp:433
bool isCellEmptyInChannel(const std::string &channel, int cellX, int cellY) const
已放置建筑实例查询。
Definition PlacementWorld.cpp:384
int removeBuildingCascade(int instanceId)
Compatibility-only script projection of the canonical Result removal API.
Definition PlacementWorld.cpp:782
int getBuildingSupportAt(int instanceId, int index) const
Direct structural support id by stable footprint order, or zero.
Definition PlacementWorld.cpp:448
int getBuildingCellX(int instanceId) const
Returns the building cell x.
Definition PlacementWorld.cpp:399
float cellToWorld3DX(int cellX, int cellY, float elevation) const
Cell to world 3 dx.
Definition PlacementWorld.cpp:168
bool buildingHasTag(int instanceId, const std::string &tag) const
Building has tag.
Definition PlacementWorld.cpp:612
int placeAt(const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
Place at.
Definition PlacementWorld.cpp:636
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:685
void setFloorHeight(float height)
Set positive height between discrete floors. Invalid values are ignored.
Definition PlacementWorld.cpp:281
std::vector< EdgeCurveGroupId > edgeCurveGroupIds() const
Return an owning ascending list of all curve-group identities.
Definition PlacementWorld.cpp:675
void setExtra(const std::string &key, const std::string &value)
世界级额外属性(键值)。
Definition PlacementWorld.cpp:54
int getAnyCornerOccupantAtLevel(int vertexX, int vertexY, int level) const
Query the first corner occupant across channels at an explicit floor.
Definition PlacementWorld.cpp:521
void setTerrain(int cellX, int cellY, int semantic)
Sets the terrain.
Definition PlacementWorld.cpp:212
float getBuildingRotation(int instanceId) const
Returns the building rotation.
Definition PlacementWorld.cpp:594
int64_t getBuildingSurfaceRevision(int instanceId) const
Surface provider revision captured when this instance was placed.
Definition PlacementWorld.cpp:569
int worldToCell3DX(float worldX, float worldY, float worldZ) const
World to cell 3 dx.
Definition PlacementWorld.cpp:193
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:467
bool canPlaceFree(const std::string &buildingId, float worldX, float worldY)
Can place free.
Definition PlacementWorld.cpp:723
int placeAtWorld3D(const std::string &buildingId, float worldX, float worldY, float worldZ, float rotationDeg=0.f)
Place at world 3 d.
Definition PlacementWorld.cpp:646
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:472
bool canPlace(const std::string &buildingId, int cellX, int cellY, float rotationDeg=0.f)
便捷操作(转发 PlacementSystem):放置 / 移除 / 移动。
Definition PlacementWorld.cpp:624
void swapState(PlacementWorld &candidate) noexcept
Atomically exchange complete logical state with a prepared candidate.
Definition PlacementWorld.cpp:786
std::string getEdgeVariant(int instanceId) const
Stable topology variant name for an edge instance.
Definition PlacementWorld.cpp:560
void cellToWorldPlane(int cellX, int cellY, float &px, float &py) const
Cell to world plane.
Definition PlacementWorld.cpp:149
eve::Result< EdgeCurveGroup > edgeCurveGroupForInstance(int instanceId) const
Return the owning curve-group snapshot linked by an edge instance.
Definition PlacementWorld.cpp:665
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:510
void setBuildingProp(int instanceId, const std::string &key, const std::string &value)
Sets the building prop.
Definition PlacementWorld.cpp:605
std::string getBuildingId(int instanceId) const
Returns the building id.
Definition PlacementWorld.cpp:394
eve::Result< EdgeCurveGroup > edgeCurveGroup(EdgeCurveGroupId id) const
Return an owning curve-group snapshot.
Definition PlacementWorld.cpp:655
std::string getExtra(const std::string &key, const std::string &fallback={}) const
Returns the extra.
Definition PlacementWorld.cpp:58
int worldToCell3DY(float worldX, float worldY, float worldZ) const
World to cell 3 dy.
Definition PlacementWorld.cpp:199
void setStagger(const std::string &axis, const std::string &index)
Sets the stagger.
Definition PlacementWorld.cpp:88
int placeAtWorld(const std::string &buildingId, float worldX, float worldY, float rotationDeg=0.f)
Place at world.
Definition PlacementWorld.cpp:641
int getCornerOccupant(const std::string &channel, int vertexX, int vertexY) const
Query a corner-domain occupant at the active floor.
Definition PlacementWorld.cpp:505
int getAnyOccupant(int cellX, int cellY) const
Returns the any occupant.
Definition PlacementWorld.cpp:357
void worldToCell3D(float worldX, float worldY, float worldZ, int &cellX, int &cellY) const
World to cell 3 d.
Definition PlacementWorld.cpp:186
std::string canPlaceCornerReason(const std::string &buildingId, int vertexX, int vertexY)
Stable corner placement rejection token.
Definition PlacementWorld.cpp:710
std::string canRemoveBuildingReason(int instanceId) const
Stable rejection token for ordinary removal (support_in_use when depended on).
Definition PlacementWorld.cpp:777
float cellToWorld3DY(int cellX, int cellY, float elevation) const
Cell to world 3 dy.
Definition PlacementWorld.cpp:174
int getAnyOccupantAtLevel(int cellX, int cellY, int level) const
Query the first occupant across channels at an explicit floor.
Definition PlacementWorld.cpp:361
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:536
std::string getBuildingSurfaceId(int instanceId) const
Surface provider identity captured when this instance was placed.
Definition PlacementWorld.cpp:564
std::string getBuildingChannel(int instanceId) const
Returns the building channel.
Definition PlacementWorld.cpp:589
void setTerrainGidMapJson(const std::string &json)
Sets the terrain gid map json.
Definition PlacementWorld.cpp:256
float getBuildingWorldZ(int instanceId) const
Returns the building world z.
Definition PlacementWorld.cpp:424
int getOccupantInChannel(const std::string &channel, int cellX, int cellY) const
Returns the occupant in channel.
Definition PlacementWorld.cpp:335
bool canPlaceCorner(const std::string &buildingId, int vertexX, int vertexY)
Validate corner placement without mutation.
Definition PlacementWorld.cpp:706
float getBuildingSurfaceNormalY(int instanceId) const
Y component of the unit surface normal captured at placement time.
Definition PlacementWorld.cpp:579
float cellToWorld3DZ(int cellX, int cellY, float elevation) const
Cell to world 3 dz.
Definition PlacementWorld.cpp:180
std::vector< int > & channelOccupancy(const std::string &channel)
Channel occupancy.
Definition PlacementWorld.cpp:314
void cellToWorld3D(int cellX, int cellY, float elevation, float &worldX, float &worldY, float &worldZ) const
Cell to world 3 d.
Definition PlacementWorld.cpp:153
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:532
int getBuildingDependentCount(int instanceId) const
Number of instances that directly depend on this instance.
Definition PlacementWorld.cpp:456
ECS tile layer entity. Script mutates tile GIDs / tileset / draw; TileRenderSystem batch-draws atlas ...
Definition TileLayer.h:33
uint64_t nextEpoch()
Definition BuildingAssemblyGeometry.cpp:11
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:10
@ 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:49
int level
Authoritative discrete floor coordinate used by occupancy and topology.
Definition BuildingTypes.h:211
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