Skip to content

Class

PlacementMount2D

Generated GDScript class reference for GridPlacement.PlacementMount2D.

Status
Draft
Version
v6.0
Updated
Development docs generated from GDScript source

This is unreleased documentation in active development. APIs, class names, and behavior may change before the final release.

Typed value object for how a placed 2D object is mounted. The 2D sibling of [PlacementMount]. That class carries a 3D column plus an EDGE/FACE/CORNER/TOP socket key because in 3D "on top of" is a half-space derived from the host's bounding box. In 2D the placement grid is a [TileMapLayer] in the X/Y plane and there is no third axis to hang a socket off, so this contract uses a [b]second, explicit occupancy axis[/b] instead of reusing one: [codeblock] key = (host_cell, host_slot, slot_index) [/codeblock] [b]Why not z_index[/b]: [code]z_index[/code] is a render property in 2D. It is already spent on indicator layering ([constant IndicatorFactory2D.DEFAULT_Z_INDEX] = 150, preview at 200), so a stacking feature built on it would be a drawing trick with no occupancy meaning. The slot key below is a real placement fact. [b]Admitted by [PlacementWorldRegistry][/b]: the shared registry gates every record on a mount validator chosen by [member PlacementWorldRecord.dimension]. [constant PlacementWorldRecord.Dimension.TWO_D] routes to [method is_valid_dict] here, and THREE_D keeps the 3D [method PlacementMount.is_valid_dict] unchanged — the two contracts are never widened into each other, and an unknown dimension keeps the 3D behaviour. A mount from [method to_dict] is therefore accepted by [method PlacementWorldRegistry.register] and survives the save boundary ([method validate_saved_states], [method PlacementWorldRecord.to_save_data]) like any other mount. [b]Slot geometry is grid-local[/b]: [member surface_size_cells] is measured in CELLS, not pixels, so the same catalog works at any tile size. [method seat_offset_pixels] converts with the live tile size at the moment of placement. [b]Deliberately additive[/b]: [enum Type.CELL] is 0 and every existing 2D save record still reads as a CELL mount, so a world written by a build without this file restores unchanged.

Source: addons/grid_placement/systems/building/2d/placement_mount_2d.gd

Syntax

class PlacementMount2D extends RefCounted

Members

NameKindSummary
KEY_TYPEFieldHow a 2D object attaches to its world. CELL is the default and the only member before surface stacking existed. String keys used by [method to_dict] / [method from_dict]. Centralized so the service, persistence layer, and demo never spell them inline.
KEY_HOST_CELLField
KEY_HOST_SLOTField
KEY_SLOT_INDEXField
MIN_SURFACE_SIZE_CELLSFieldA host declares its top surface in whole cells (or a fraction of one) on each axis. The surface is the rectangle [code][0, size)[/code] measured from the host's own grid seat, so slot (0,0) always exists for any host of at least 1x1.
MAX_SURFACE_SIZE_CELLSFieldA host may not declare a surface larger than this on either axis. Bounds the slot count a single host can create so a typo in a catalog resource cannot make the slot space explode.
MAX_SLOT_INDEXFieldLargest slot_index a surface mount may claim. Bounds hostile save data: a record claiming slot 2^30 would otherwise allocate a validation loop that long. Real hosts stay far below this.
typeProperty
host_cellPropertyThe grid cell the HOST occupies (its minimum corner for a multi-cell host).
host_slotPropertyThe host's stacked height in cells, counting from its own seat upward. 0 = a ground-level object that offers no surface.
slot_indexPropertyWhich slot of that height band the stacked object claims.
entryPropertyIn-memory only. Not serialized: a [Resource] does not survive a JSON round-trip, so the restore side supplies it explicitly.
for_cellMethod
for_surfaceMethod
mProperty
is_surfaceMethod
slot_keyMethod
band_keyMethod
slot_count_forMethod
surface_extent_cellsMethod
slot_cell_offsetMethod
BAND_CLEARANCE_CELLSFieldCells of clear space one stacked band leaves above the surface it stacks on, on top of the surface's own depth. Exposed as a constant because it is the one number that makes the two occupancy axes resolve in the same unit: [param p_slot_index] walks the surface in cells, and the band must do the same or the identity has no position at all.
band_lift_cellsMethod
seat_offset_pixelsMethod
extentProperty
col_rowProperty
from_min_cornerProperty
from_centerProperty
to_dictMethod
from_dictMethod
is_valid_dictMethod
apply_toMethod