Skip to content

Class

PlacementMount2D

Generated GDScript class reference for GridPlacement.PlacementMount2D.

Status
Current
Version
v6.3.0
Source updated
2026-10-29
Generated on
2026-10-29

6.3. These pages document the 6.3 release, where placeable is now entry (what changed) and PlacementOwner is deprecated (migration). Still on 6.2? Your version's guides ship inside the plugin itself, under addons/grid_placement/guides/; the 6.2 URLs on this site now redirect to this series.

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 second, explicit occupancy axis instead of reusing one: key = (host_cell, host_slot, slot_index) Why not z_index: z_index is a render property in 2D. It is already spent on indicator layering (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. Admitted by PlacementWorldRegistry: the shared registry gates every record on a mount validator chosen by PlacementWorldRecord.dimension. PlacementWorldRecord.Dimension.TWO_D routes to is_valid_dict() here, and THREE_D keeps the 3D 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 to_dict() is therefore accepted by PlacementWorldRegistry.register() and survives the save boundary (validate_saved_states(), PlacementWorldRecord.to_save_data()) like any other mount. Slot geometry is grid-local: surface_size_cells is measured in CELLS, not pixels, so the same catalog works at any tile size. seat_offset_pixels() converts with the live tile size at the moment of placement. Deliberately additive: 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 to_dict() / 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 [0, size) 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: 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