Skip to content

PlacementValidator

Runs tests for each rule using RuleCheckIndicators to determine if placement in the targeted location is valid if all rules validate successfully

const ISSUE_MATCHING_PRIORITY = “Info: %d rules share visual priority [%d] %s (allowed)“
signal finished( results: ValidationResults )

Emitted when the placement validator is done evaluating a set of rules on a scene node

signal setup_failed( issues: Dictionary[PlacementRule, Array] )

Emitted when the setup failed

active_rules: Array[PlacementRule] = []

Rules that are enforced whenever placing any object into the game world by default Exists so you don’t have to add the same rule to every single object individually

Debug settings to pass into rules. Override in resource inspector if desired.

Full list of rules being used by the placement validator to test object placement

static func create_with_injection( container: GBCompositionContainer ) -> PlacementValidator

Creates a PlacementValidator with dependency injection from container. Container serves as single source of truth for all dependencies. Parameters: container: GBCompositionContainer - The dependency container Returns: PlacementValidator - Fully configured placement validator with validated dependencies

func _init( p_base_rules: Array[PlacementRule], p_logger: GBLogger ) -> void
func resolve_gb_dependencies( container: GBCompositionContainer ) -> bool

Passes. No injection needed. Returns: bool - True if dependencies were successfully resolved, false otherwise

func get_runtime_issues( ) -> Array[String]

Validates that all required dependencies are properly set. Returns: Array[String] - List of validation issues (empty if valid)

func validate_placement( ) -> ValidationResults

Validates placement rules against the current target state. Returns the validation results including details of each placement rule result.

Returns: ValidationResults - Comprehensive validation results with rule details and success status

func _handle_validation_orchestration( results: ValidationResults ) -> void

Handles orchestration aspects of validation (logging, result processing)

func _setup_rules( p_rules: Array[PlacementRule], p_gts: GridTargetingState ) -> Dictionary

Tries setup on all of the p_rules PlacementRule Uses pure logic class for composition over inheritance Returns a dictionary PlacementRules and the issues found for each rule that had issues [param] p_rules : Array[PlacementRule] - The placement rules to setup [param] p_gts : GridTargetingState - The current grid targeting state

func setup( p_rules: Array[PlacementRule], p_gts: GridTargetingState ) -> Dictionary

Sets the active rules set and rule_check_indicators for validating the current target’s placement position Uses pure logic class for composition over inheritance Returns a dictionary of issues

func get_combined_rules( p_outside_rules: Array, false: p_ignore_base = ) -> Array[PlacementRule]

Gets the rules of the placement validator combined with the rules of the placeable resource Uses pure logic class for composition over inheritance

func _pre_check_tile_rules( p_tile_check_rules: Array[TileCheckRule] )
func tear_down( )

Tear down base & placeable specific rules

func apply_rules( )

Clean up null indicators from all active tile check rules. This prevents null reference errors during validation. Uses pure logic for composition over inheritance Runs execute on each of the active rules

This is code that generally runs after validation is successful and the validated action takes place

addons/grid_building/placement/manager/components/placement_validator.gd


This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.