CollisionsCheckRule
AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
Source: placement/placement_rules/template_rules/collisions_check_rule.gd
Version: 5.0
class_name: CollisionsCheckRule
extends: TileCheckRule
Summary
Rule that validates placement based on collision detection.
This rule checks for physics collisions at indicator positions and validates based on the [member pass_on_collision] setting:
- [code]false[/code] (default): Placement FAILS if collision detected (“must have clear space”)
- [code]true[/code]: Placement FAILS if NO collision detected (“must overlap with existing objects”)
Signals
(none)
Exports
pass_on_collision- Controls collision validation behavior:
- [code]false[/code]: Rule PASSES when no collision (placement requires clear space)
- [code]true[/code]: Rule PASSES when collision detected (placement requires overlap)
Common use cases:
- [code]false[/code]: Building placement (needs empty space)
- [code]true[/code]: Attachment mechanics (must connect to existing structures)
messages- Modular message configuration resource
Methods
_init()setup()- Setup the rule with the provided GridTargetingState. Returns an array of issues found during setup. [code]p_gts[/code]: [i]GridTargetingState[/i] - The targeting state to use for placement [returns] Array[String] - Array of issues found during setup
validate_placement()- Validates placement by checking collisions on all provided indicators. Returns a RuleResult with success/failure and messages.
get_failing_indicators()- Runs the rule against an array of indicators.
Returns the number of failing indicators.[br][br]
[code]p_indicators[/code]: [i]Array[RuleCheckIndicator][/i] - Array of indicators to test collision against
NOTE: This method is public and should be used directly by callers. The previous
private wrapper
_get_failing_indicatorswas removed to simplify the API.
- Runs the rule against an array of indicators.
Returns the number of failing indicators.[br][br]
[code]p_indicators[/code]: [i]Array[RuleCheckIndicator][/i] - Array of indicators to test collision against
NOTE: This method is public and should be used directly by callers. The previous
private wrapper
_indicator_apply_target_exceptions()- Add all CollisionObject2D under the preview target as exceptions on the shape cast. Also adds any nodes from GridTargetingState.collision_exclusions (e.g., original object during manipulation move).
_collect_bodies_recursive()get_editor_issues()- Returns an array of issues found during editor validation
get_runtime_issues()- Returns an array of issues found during runtime validation