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 RefCountedMembers
| Name | Kind | Summary |
|---|---|---|
KEY_TYPE | Field | How 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_CELL | Field | |
KEY_HOST_SLOT | Field | |
KEY_SLOT_INDEX | Field | |
MIN_SURFACE_SIZE_CELLS | Field | A 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_CELLS | Field | A 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_INDEX | Field | Largest 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. |
type | Property | |
host_cell | Property | The grid cell the HOST occupies (its minimum corner for a multi-cell host). |
host_slot | Property | The host's stacked height in cells, counting from its own seat upward. 0 = a ground-level object that offers no surface. |
slot_index | Property | Which slot of that height band the stacked object claims. |
entry | Property | In-memory only. Not serialized: a Resource does not survive a JSON round-trip, so the restore side supplies it explicitly. |
for_cell | Method | |
for_surface | Method | |
m | Property | |
is_surface | Method | |
slot_key | Method | |
band_key | Method | |
slot_count_for | Method | |
surface_extent_cells | Method | |
slot_cell_offset | Method | |
BAND_CLEARANCE_CELLS | Field | Cells 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_cells | Method | |
seat_offset_pixels | Method | |
extent | Property | |
col_row | Property | |
from_min_corner | Property | |
from_center | Property | |
to_dict | Method | |
from_dict | Method | |
is_valid_dict | Method | |
apply_to | Method |