Class PlacementValidationContext
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
Context object carrying all necessary data for placement validation. Supports both object-based (via indicators) and terrain-based (via cells) validation.
class PlacementValidationContext extends RefCounted
Properties
action_type
The type of action being validated.
var action_type: ActionType = ActionType.NONE
cell
The cell being validated.
var cell: Vector2i
terrain_name
The terrain name (if in PAINT_TILE mode).
var terrain_name: StringName
placeable
The placeable resource (if in PLACE_OBJECT mode).
var placeable: ScenePlacementEntry
preview_cells
All cells currently being placed/previewed (for adjacency checks in a brush). Also known as batch cells.
var preview_cells: Array[Vector2i]
indicator
The indicator being validated (if in PLACE_OBJECT mode).
var indicator: RuleCheckIndicator
target_map
The target TileMapLayer.
var target_map: TileMapLayer
targeting_state
Reference to the targeting state for occupancy and collision queries.
var targeting_state: GridTargetingState
shared_cache
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.
var shared_cache: Dictionary = {}
ctx
var ctx = PlacementValidationContext.new()
ctx
var ctx = PlacementValidationContext.new()
Methods
for_terrain
static func for_terrain(p_cell: Vector2i, p_terrain: StringName, p_preview_cells: Array[Vector2i], p_map: TileMapLayer, p_gts: GridTargetingState = null) -> PlacementValidationContext:
Parameters
p_cellp_terrainp_preview_cellsp_mapp_gts
Returns
for_object
static func for_object(p_indicator: RuleCheckIndicator, p_placeable: ScenePlacementEntry, p_map: TileMapLayer, p_gts: GridTargetingState = null) -> PlacementValidationContext:
Parameters
p_indicatorp_placeablep_mapp_gts