载入中...
搜索中...
未找到
Building.cpp
浏览该文件的文档.
static int loadFromJson(const std::string &json, std::string *error=nullptr)
从 JSON 数组或单对象批量注册,返回成功数量。 元素形如: { "id": "house.wood", "displayName": "木屋", "category": "housing",...
Definition BuildingDef.cpp:178
std::string getBuildingRotationMode(const std::string &buildingId)
Returns the building rotation mode.
Definition Building.cpp:49
int registerBuildingsFromJson(const std::string &json)
从 JSON 注册建筑模板;返回成功注册数量。
Definition Building.cpp:11
int getChangeEventInstanceId(int index) const
Returns the change event instance id.
Definition Building.cpp:170
std::string getBuildingDisplayName(const std::string &buildingId)
Returns the building display name.
Definition Building.cpp:24
std::string getBuildingConnectionGroup(const std::string &buildingId)
Definition edge connection group, or empty when it falls back to id.
Definition Building.cpp:74
std::string getChangeEventBuildingId(int index) const
Returns the change event building id.
Definition Building.cpp:164
std::string getBuildingVisual3d(const std::string &buildingId, const std::string &key, const std::string &fallback={})
Returns the building visual 3 d.
Definition Building.cpp:85
float getChangeEventRotation(int index) const
Returns the change event rotation.
Definition Building.cpp:200
int getBuildingFootprintW(const std::string &buildingId)
Returns the building footprint w.
Definition Building.cpp:34
std::string getBuildingSnapMode(const std::string &buildingId)
Returns the building snap mode.
Definition Building.cpp:44
std::string getBuildingExtra(const std::string &buildingId, const std::string &key, const std::string &fallback={})
Returns the building extra.
Definition Building.cpp:96
bool buildingHasTag(const std::string &buildingId, const std::string &tag)
Building has tag.
Definition Building.cpp:91
int getBuildingCost(const std::string &buildingId, const std::string &resource)
Returns the building cost.
Definition Building.cpp:102
std::string getBuildingCategory(const std::string &buildingId)
Returns the building category.
Definition Building.cpp:29
std::string getBuildingChannel(const std::string &buildingId)
Returns the building channel.
Definition Building.cpp:59
PlacementSession * newSession()
Creates a session. @ownership Caller deletes unless documented otherwise.
Definition Building.cpp:117
std::string getChangeEventAction(int index) const
Returns the change event action.
Definition Building.cpp:152
std::string getChangeEventWorldId(int index) const
Returns the change event world id.
Definition Building.cpp:158
int getBuildingFootprintH(const std::string &buildingId)
Returns the building footprint h.
Definition Building.cpp:39
std::string getBuildingVisual2d(const std::string &buildingId, const std::string &key, const std::string &fallback={})
Returns the building visual 2 d.
Definition Building.cpp:79
std::string getBuildingRenderMode(const std::string &buildingId)
Returns the building render mode.
Definition Building.cpp:64
int getChangeEventOtherCellY(int index) const
Returns the change event other cell y.
Definition Building.cpp:194
std::string getBuildingValidateRule(const std::string &buildingId)
Returns the building validate rule.
Definition Building.cpp:54
bool hasBuildingDefinition(const std::string &buildingId)
建筑模板查询(显示名/类别/占地/规则/标签/额外属性/成本)。
Definition Building.cpp:20
std::string getBuildingPlacementKind(const std::string &buildingId)
Definition placement domain (cell or edge).
Definition Building.cpp:69
int getChangeEventOtherCellX(int index) const
Returns the change event other cell x.
Definition Building.cpp:188
Ghost * newGhost()
Creates a ghost. @ownership Caller deletes unless documented otherwise.
Definition Building.cpp:112
PlacementWorld * newWorld(int width, int height, float cellSize=32.f)
工厂:创建放置世界 / 鬼影。
Definition Building.cpp:107
float getSurfaceHeightDelta() const
Sampled elevation range across the complete footprint.
Definition Ghost.h:91
void setFree(PlacementWorld *world, float worldX, float worldY, float elevation=0.f)
Set an exact unsnapped world-plane anchor for a free-domain definition.
Definition Ghost.cpp:207
void setFromWorld(PlacementWorld *world, float worldX, float worldY)
按世界吸附模式,从世界坐标刷新格子与世界位姿。
Definition Ghost.cpp:105
float getSurfaceTangentX() const
X component of the captured unit surface tangent.
Definition Ghost.h:81
std::string getSurfaceId() const
Surface identity captured by the last successful setFromSurface call.
Definition Ghost.h:71
void setFromWorld3D(PlacementWorld *world, float worldX, float worldY, float worldZ)
Sets the from world 3 d.
Definition Ghost.cpp:131
void setCorner(PlacementWorld *world, int vertexX, int vertexY)
Snap this ghost to one canonical grid vertex.
Definition Ghost.cpp:190
std::string getPlacementKind() const
Current placement domain (cell, edge, corner, or free).
Definition Ghost.h:56
float getSurfaceTangentZ() const
Z component of the captured unit surface tangent.
Definition Ghost.h:85
std::string getEdgeAxis() const
Canonical edge axis (horizontal/vertical), empty for cell ghosts.
Definition Ghost.cpp:157
void setEdge(PlacementWorld *world, int cellX, int cellY, const std::string &direction)
Snap this ghost to a canonicalized cell edge and its exact midpoint pose.
Definition Ghost.cpp:162
float getSurfaceTangentY() const
Y component of the captured unit surface tangent.
Definition Ghost.h:83
int getSurfaceSampleCount() const
Number of occupied footprint cells sampled in the current patch.
Definition Ghost.h:87
int64_t getSurfaceRevision() const
Surface revision captured by the last successful setFromSurface call.
Definition Ghost.h:73
float getSurfaceNormalY() const
Y component of the captured unit surface normal.
Definition Ghost.h:77
float getSurfaceMaxSlopeDegrees() const
Maximum sampled slope relative to the grid-plane up axis.
Definition Ghost.h:89
float getSurfaceNormalZ() const
Z component of the captured unit surface normal.
Definition Ghost.h:79
void setFromSurface(PlacementWorld *world, const std::string &surface, float x, float y)
Sets the from surface.
Definition Ghost.cpp:225
float getSurfaceNormalX() const
X component of the captured unit surface normal.
Definition Ghost.h:75
PlacementEditExecuteStatus executeReplace(int instanceId)
Replace an existing instance with the selected definition atomically.
Definition PlacementSession.cpp:365
PatternUpdateStatus setPatternSubdivisions(int subdivisions)
Configure analytic segments used by edge_cubic_bezier.
Definition PlacementSession.cpp:496
PatternUpdateStatus setPatternRadius(int radius)
Configure the circle radius used by circle_brush.
Definition PlacementSession.cpp:490
int getAreaPreviewCount() const
Number of cells in the last successful preview.
Definition PlacementSession.h:160
AreaExecuteStatus previewBrush(int centerCellX, int centerCellY, int radius)
Cache a non-mutating circular cell brush preview.
Definition PlacementSession.cpp:392
std::string getPatternKind() const
Stable name of the currently authored pattern, or empty.
Definition PlacementSession.cpp:541
int getLastPlacedCount() const
Number of ids committed by the last successful edge-line operation.
Definition PlacementSession.h:142
bool startPlacement(PlacementWorld *world, const std::string &buildingId)
Starts placement.
Definition PlacementSession.cpp:83
PatternUpdateStatus setPatternSurface(const std::string &surfaceName)
Configure an optional named surface for edge_cubic_bezier.
Definition PlacementSession.cpp:502
int getAreaPreviewCellX(int index) const
Returns the area preview cell x.
Definition PlacementSession.cpp:440
bool getPatternPreviewAccepted(int index) const
Whether one concrete preview anchor passed validation.
Definition PlacementSession.cpp:569
FreeUpdateStatus updateFree(PlacementWorld *world, float worldX, float worldY, float elevation=0.f)
Refresh a free-object ghost at an exact world-plane position.
Definition PlacementSession.cpp:183
int getLastEditedId() const
Instance id affected by the last successful move/replace, or zero.
Definition PlacementSession.h:150
PlacementEditExecuteStatus executeMove(int instanceId)
Move an existing instance to the current domain-specific ghost pose atomically.
Definition PlacementSession.cpp:338
PatternUpdateStatus beginPattern(const std::string &kind)
Start a renderer-neutral built-in pattern request.
Definition PlacementSession.cpp:454
AreaExecuteStatus previewRectangle(int minCellX, int minCellY, int maxCellX, int maxCellY)
Cache a non-mutating inclusive rectangular preview for UI/BuildingFX.
Definition PlacementSession.cpp:376
int getPatternPointCount() const
Number of authoring points in the current pattern.
Definition PlacementSession.h:192
EdgePathUpdateStatus appendEdgeCurveControlPoint(float x, float y)
Append a cubic Bezier control point; exactly four controls are accepted.
Definition PlacementSession.cpp:291
bool getAreaPreviewAccepted(int index) const
Returns the area preview accepted.
Definition PlacementSession.cpp:446
int getPatternPreviewX(int index) const
Logical x coordinate for one concrete preview anchor, or zero.
Definition PlacementSession.cpp:545
int getAreaPreviewCellY(int index) const
Returns the area preview cell y.
Definition PlacementSession.cpp:443
EdgeUpdateStatus updateEdge(PlacementWorld *world, int cellX, int cellY, const std::string &direction)
Refresh an edge-object ghost from a cell-relative cardinal edge.
Definition PlacementSession.cpp:163
bool updateFromWorld3D(PlacementWorld *world, float worldX, float worldY, float worldZ)
Updates from world 3 d.
Definition PlacementSession.cpp:143
EdgeLineExecuteStatus executeEdgeLine(int startVertexX, int startVertexY, int endVertexX, int endVertexY)
Atomically place an axis-aligned edge line between logical vertices.
Definition PlacementSession.cpp:230
std::string getPatternPreviewReason(int index) const
Stable rejection reason for an area anchor, or empty.
Definition PlacementSession.cpp:575
AreaExecuteStatus executeBrush(int centerCellX, int centerCellY, int radius)
Atomically place a circular brush using the selected definition.
Definition PlacementSession.cpp:424
int getEdgeCurveControlPointCount() const
Number of currently authored cubic Bezier control points.
Definition PlacementSession.h:134
CornerUpdateStatus updateCorner(PlacementWorld *world, int vertexX, int vertexY)
Refresh a corner-object ghost at a canonical grid vertex.
Definition PlacementSession.cpp:173
EdgePathUpdateStatus appendEdgePathVertex(int vertexX, int vertexY)
Append one orthogonally connected logical vertex to the current edge path.
Definition PlacementSession.cpp:255
int getPatternPreviewCount() const
Number of concrete edge/cell anchors in the last pattern preview.
Definition PlacementSession.h:196
bool updateFromWorld(PlacementWorld *world, float worldX, float worldY)
Updates from world.
Definition PlacementSession.cpp:134
EdgeLineExecuteStatus executeEdgePath()
Atomically commit the complete edge path.
Definition PlacementSession.cpp:264
AreaExecuteStatus executeRectangle(int minCellX, int minCellY, int maxCellX, int maxCellY)
Atomically place an inclusive rectangle using the selected definition.
Definition PlacementSession.cpp:407
EdgeLineExecuteStatus executeEdgeCurveOnSurface(int subdivisions, const std::string &surfaceName)
Sample a named custom surface and atomically commit the authored curve.
Definition PlacementSession.cpp:315
EdgePathUpdateStatus beginEdgePath(int vertexX, int vertexY)
Start a multi-segment edge path at one logical grid vertex.
Definition PlacementSession.cpp:245
PatternExecuteStatus executePattern()
Atomically commit the complete cached pattern request.
Definition PlacementSession.cpp:526
PatternUpdateStatus appendPatternPoint(float x, float y)
Append one logical grid point/control to the current pattern.
Definition PlacementSession.cpp:471
EdgeLineExecuteStatus executeEdgeCurve(int subdivisions)
Sample and atomically commit the authored cubic Bezier curve.
Definition PlacementSession.cpp:299
EdgePathUpdateStatus beginEdgeCurve(float x, float y)
Begin authoring four cubic Bezier controls in logical grid space.
Definition PlacementSession.cpp:280
std::string getPatternPreviewAxis(int index) const
Edge axis for an edge preview anchor, or empty for area anchors.
Definition PlacementSession.cpp:559
PatternUpdateStatus previewPattern()
Expand and cache the complete pattern without world mutation.
Definition PlacementSession.cpp:510
bool updateFromSurface(PlacementWorld *world, const std::string &surface, float x, float y)
Updates from surface.
Definition PlacementSession.cpp:153
int getLastPlacedId(int index) const
Instance id from the last successful edge-line operation, or zero.
Definition PlacementSession.cpp:333
int getEdgePathVertexCount() const
Number of logical vertices in the current edge path.
Definition PlacementSession.h:117
int getPatternPreviewY(int index) const
Logical y coordinate for one concrete preview anchor, or zero.
Definition PlacementSession.cpp:552
std::string getAreaPreviewReason(int index) const
Returns the area preview reason.
Definition PlacementSession.cpp:449
static std::vector< std::string > surfaceNames()
Definition PlacementSystem.cpp:529
static const std::vector< BuildingChangeEvent > & events()
Definition PlacementSystem.cpp:651
static float getPlaneSurfaceHeight()
Definition PlacementSystem.cpp:539
static void setPlaneSurfaceHeight(float h)
Definition PlacementSystem.cpp:537
static bool hasSurface(const std::string &name)
Definition PlacementSystem.cpp:392
static bool hasSnapRule(const std::string &name)
Definition PlacementSystem.cpp:321
static void clearEvents()
Definition PlacementSystem.cpp:649
static bool hasValidateRule(const std::string &name)
Definition PlacementSystem.cpp:309
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
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 getActiveLevel() const
Floor used by compatibility placement/query APIs.
Definition PlacementWorld.h:72
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
void setGridFromLayer(map::TileLayer *layer)
Sets the grid from layer.
Definition PlacementWorld.cpp:92
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
float getFloorHeight() const
Height between discrete floors along the grid plane normal.
Definition PlacementWorld.h:68
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
void setExtra(const std::string &key, const std::string &value)
世界级额外属性(键值)。
Definition PlacementWorld.cpp:51
void setActiveLevel(int level)
Select the floor used by compatibility placement/query APIs.
Definition PlacementWorld.h:74
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
std::string getEdgeVariant(int instanceId) const
Stable topology variant name for an edge instance.
Definition PlacementWorld.cpp:557
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
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
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
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
建筑放置模块入口:定义 / 放置世界 / 鬼影 / 变更事件的脚本绑定点。 设计文档:docs/dev/建筑放置系统设计.md
Definition Building.cpp:7