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 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 [method to_dict] / [method 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 [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_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: [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_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 |