real_world_indicator_test

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Source File: /addons/grid_building/test/integration/system_interactions/real_world_indicator_test.gd

Extends: GdUnitTestSuite

Properties

  • Property: indicator_manager: Variant
  • Property: targeting_state: Variant
  • Property: positioner: Variant

Private Properties

  • Property: _container: Variant (private)

    Real World Indicator Positioning Test Tests indicator generation and spatial positioning using the actual IndicatorManager pipeline with realistic collision shapes and tilemap integration, ensuring indicators are correctly positioned relative to preview objects in a real-world scenario

  • Property: _logger: Variant (private)

  • Property: _preview_ref: Variant (private)

Public Methods

before_test

1
before_test() -> void

after_test

1
after_test() -> void

test_real_world_indicator_positioning

1
test_real_world_indicator_positioning() -> void

EXPECTATION / PURPOSE This test exercises indicator generation and spatial positioning using the real IndicatorManager pipeline without bootstrapping the entire BuildingSystem dependency graph.

Setup:

  • A targeting state with a populated TileMapLayer (factory-created predictable 40x40 grid)
  • A positioner Node2D assigned to the targeting state
  • A IndicatorManager (created directly if container didn’t provide one)
  • A real placeable resource if available via GBTestConstants; otherwise a synthetic Placeable with a simple PackedScene containing a StaticBody2D + CollisionShape2D rectangle (32x32) is created.

Actions:

  • Instantiate a preview for the (real or synthetic) placeable and parent it under the positioner
  • Invoke indicator_manager.try_setup with either the placeable’s own placement_rules or a fallback simple TileCheckRule to force indicator creation

Assertions / Success Criteria:

  1. At least one indicator is generated (indicators.size() > 0) - requires >=1 TileCheckRule.
  2. Preview (or its descendants) contains >=1 CollisionShape2D or CollisionPolygon2D.
  3. At least one ancestor physics body (StaticBody2D/Area2D/RigidBody2D/CharacterBody2D) of those shapes has a collision_layer bit overlapping the TileCheckRule.apply_to_objects_mask (defaults: layer=1, mask=1).
  4. Among the sampled first N (<=5) indicators, global positions are unique (no duplicate clustering).
  5. Each sampled indicator lies within one tile-size bounds of its computed tile origin (basic grid alignment).
  6. Sampled indicators mutually differ (redundant safeguard vs uniqueness map).
  7. The average (centroid) of all indicator positions is within 256 world units of the preview’s center (ensures indicators relate spatially to the preview, not scattered far away).
  8. Targeting state validation reports no issues (positioner and target_map assigned, maps non-empty). Notes:
  • Indicators only generate if there is at least one TileCheckRule present.
  • Collision layer/mask alignment is a hard precondition: without a matching layer->mask bitwise AND, no indicators spawn.

Rationale: This codifies a “real world” integration slice focused on indicator placement semantics while staying resilient to missing higher-level systems. The explicit spread + proximity constraints give early signal if collision-to-indicator mapping regresses, offsets break, or manager setup silently fails.


Private Methods

_instantiate_preview

1
_instantiate_preview(packed_scene: PackedScene) -> Node2D

Flags: private


_get_collision_shapes_from_node

1
_get_collision_shapes_from_node(root: Node) -> Array[Node]

Flags: private


_find_physics_body_ancestor

1
_find_physics_body_ancestor(node: Node) -> Node

Flags: private


_validate_indicator_positions

1
2
3
4
_validate_indicator_positions(
    indicators: Array[RuleCheckIndicator],
    preview: Node2D
) -> void

Flags: private



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