Context object carrying all necessary data for placement validation. Supports both object-based (via indicators) and terrain-based (via cells) validation.
Source: addons/grid_placement/placement/placement_rules/placement_validation_context.gd
Syntax
class PlacementValidationContext extends RefCountedMembers
| Name | Kind | Summary |
|---|---|---|
action_type | Property | The type of action being validated. |
cell | Property | The cell being validated. |
cell_3d | Property | The 3D cell being validated. Set only by [method for_terrain_3d]; the 2D [member cell] stays at its default so 2D-only rules never observe a 3D paint through a 2D coordinate. |
terrain_name | Property | The terrain name (if in PAINT_TILE mode). |
placeable | Property | The placeable resource (if in PLACE_OBJECT mode). |
preview_cells | Property | All cells currently being placed/previewed (for adjacency checks in a brush). Also known as batch cells. |
preview_cells_3d | Property | 3D batch cells for multi-cell 3D terrain validation. Set only by [method for_terrain_3d]. |
indicator | Property | The indicator being validated (if in PLACE_OBJECT mode). |
target_map | Property | The target TileMapLayer. |
target_map_3d | Property | The target GridMap for 3D terrain validation. Set only by [method for_terrain_3d]. |
is_3d | Property | True when this context describes a 3D terrain paint. The validation pipeline runs only rules that opt into 3D (see [method TilePaintRule.supports_3d_terrain]) so 2D-only rules never observe 3D coordinates they cannot interpret. |
targeting_state | Property | Reference to the targeting state for occupancy and collision queries. |
world_facts_provider_2d | Property | Optional game-owned provider for placement-relevant world/physics facts. Grid Placement consumes this abstraction but does not own the backend (Godot Physics, Avian 2D, custom simulation, etc.). |
shared_cache | Property | Per-batch scratch cache shared across every cell context in one multi-cell validation pass (line/rect/outline/flood). Rules memoize expensive, cell-independent resolutions here (e.g. a terrain's collision polygons) so a batch resolves them once instead of once per cell. Empty for single-cell validation. Lifetime = one batch; never global static state. |
for_terrain | Method | |
ctx | Property | |
for_terrain_3d | Method | |
ctx | Property | |
for_object | Method | |
ctx | Property |