Grid Placement

WithinTilemapBoundsRule

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: systems/placement/validators/placement_rules/template_rules/within_tilemap_bounds_rule.gd

Version: 5.1

class_name: WithinTilemapBoundsRule extends: TileCheckRule

Summary

A rule that validates placement is within the boundaries of a tilemap.

This rule works by checking if a tile exists at a proposed placement position on the target TileMapLayer. It ensures that a player or system cannot place objects in empty, unmapped areas of the scene.

Behavior:

  • The rule passes if every indicator is positioned over a cell that has an assigned TileData object on the target map.
  • The rule fails if any indicator is over a cell that returns null for TileData, indicating that the cell is outside of the mapped region.

Usage:

  • Attach this rule to a GBCompositionContainer for context wide injection OR a Placeable for placeable specific rule evaluation
  • The GridTargetingState must provide a valid TileMapLayer for the rule to check against.

Signals

(none)

Exports

  • success_message
    • Success message for valid placement.
  • failed_message
    • Failure message for out-of-bounds placement.
  • enable_debug_diagnostics
    • Optional: enable extra per-indicator diagnostics during tile lookups (very verbose)

Methods

  • validate_placement()
  • get_failing_indicators()
    • Evaluates indicators against the rule and returns failing ones. Returns the failing indicators that are outside valid tilemap bounds.[br][br] [code]p_indicators[/code]: [i]Array[RuleCheckIndicator][/i] - Array of indicators to check against tilemap bounds

CRITICAL: Overrides TileCheckRule.get_failing_indicators to avoid circular dependency where the base implementation checks indicator.valid, but indicator.valid depends on rule results

  • _is_over_valid_tile()
    • Validates if an indicator is positioned over a valid tile. A tile with no tile data does not have a sprite set and is an unused tile. Returns true if TileData is found or false if not.[br][br] [code]p_indicator[/code]: [i]RuleCheckIndicator[/i] - The indicator to check position for[br] [code]p_target_map[/code]: [i]Node2D[/i] - The target map to validate against
  • _filter_critical_indicator_issues()
    • Filters indicator issues, returning only those considered critical for bounds checking
  • _is_critical_indicator_issue()
    • Determines if an issue string is critical (i.e., not cosmetic)
  • _debug_diagnostic()
    • Emits gated diagnostics when debug diagnostics are enabled