CollisionsCheckRule

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Rule that validates placement based on collision detection.

Source File: /addons/grid_building/placement/placement_rules/template_rules/collisions_check_rule.gd

Extends: TileCheckRule

Exported Properties

  • Property: pass_on_collision = false

    Controls collision validation behavior:

    • false: Rule PASSES when no collision (placement requires clear space)
    • true: Rule PASSES when collision detected (placement requires overlap)

    Common use cases:

    • false: Building placement (needs empty space)
    • true: Attachment mechanics (must connect to existing structures)
  • Property: messages : [CollisionRuleSettings](./collision-rule-settings/) - Modular message configuration resource

Properties

  • Property: collision_mask = 1 - Physics layers to scan for collisions.

Private Properties

  • Property: _rule_check_layer_names : Array[String] (private)

Public Methods

setup

1
setup(p_gts : GridTargetingState) -> Array[String]

Setup the rule with the provided GridTargetingState. Returns an array of issues found during setup. p_gts: GridTargetingState - The targeting state to use for placement [returns] Array[String] - Array of issues found during setup


validate_placement

1
validate_placement() -> RuleResult

Validates placement by checking collisions on all provided indicators. Returns a RuleResult with success/failure and messages.

NOTE: When the preview object has no collision shapes, IndicatorSetupUtils generates zero indicators. This method explicitly FAILS in that case because CollisionsCheckRule cannot perform collision tests without indicators. This is the opposite of TileCheckRule behavior, which auto-passes when no indicators exist (nothing to test = pass by design).


get_failing_indicators

1
2
3
get_failing_indicators(
    p_indicators : Array[RuleCheckIndicator]
) -> Array[RuleCheckIndicator]

Runs the rule against an array of indicators. Returns the number of failing indicators.

p_indicators: Array[RuleCheckIndicator] - 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_indicators was removed to simplify the API.


get_editor_issues

1
get_editor_issues() -> Array[String]

Returns an array of issues found during editor validation


get_runtime_issues

1
get_runtime_issues() -> Array[String]

Returns an array of issues found during runtime validation


Private Methods

_init

1
_init()

Flags: private


_ensure_messages

1
_ensure_messages() -> void

Flags: private

Ensures messages is initialized. This is critical for web-export compatibility because _init() is NOT called when Resources are loaded from .tres files. Any code that accesses messages must call this first.


_is_in_excluded_bodies

1
2
3
4
_is_in_excluded_bodies(
    collider: Node,
    excluded_bodies: Array[CollisionObject2D]
) -> bool

Flags: private

Manual exclusion filter — workaround for Godot’s ShapeCast2D.add_exception() silently failing when the cast origin is outside the excluded body’s bounds.


_indicator_apply_target_exceptions

1
_indicator_apply_target_exceptions(indicator: ShapeCast2D) -> void

Flags: private

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

1
2
3
4
_collect_bodies_recursive(
    node: Node,
    out: Array[CollisionObject2D]
) -> void

Flags: private



Grid Building v5.0.8 | Generated 24/05/2026