WithinTilemapBoundsRule
AUTO-GENERATED FILE – DO NOT EDIT MANUALLY
A rule that validates placement is within the boundaries of a tilemap.
Source File: addons/grid_building/placement/placement_rules/template_rules/within_tilemap_bounds_rule.gd
Extends: TileCheckRule
Exported Properties
- Property:
success_message : String = "Placement is within map bounds"- Success message for valid placement. - Property:
failed_message : String = "Tried placing outside of valid map area"- Failure message for out-of-bounds placement. - Property:
no_indicators_message = "No tile collision indicators to check for within tilemap bounds." - Property:
enable_debug_diagnostics: bool = false- Optional: enable extra per-indicator diagnostics during tile lookups (very verbose)
Constants
- Constant:
NON_CRITICAL_ISSUE_KEYWORDS: Array[String] = [- Issue keywords considered non-critical for bounds checking (cosmetic/setup)
Public Methods
setup
tear_down
validate_placement
For each tilemap indicator, check the tilemap to see if the tile at its position is used on any layer or not. When there are no indicators, falls back to checking visual component bounds. Note: For accurate placement validation, objects should have collision shapes to define their footprint. Visual bounds fallback is a best-effort approach for objects without collision shapes.
get_failing_indicators
Evaluates indicators against the rule and returns failing ones. Returns the failing indicators that are outside valid tilemap bounds.
p_indicators: Array[RuleCheckIndicator] - 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
Private Methods
_is_over_valid_tile
Flags: private
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.
p_indicator: RuleCheckIndicator - The indicator to check position for
p_target_map: Node2D - The target map to validate against
_filter_critical_indicator_issues
Flags: private
Filters indicator issues, returning only those considered critical for bounds checking
_is_critical_indicator_issue
Flags: private
Determines if an issue string is critical (i.e., not cosmetic)
_debug_diagnostic
Flags: private
Emits gated diagnostics when debug diagnostics are enabled
_validate_using_visual_bounds
Flags: private
Validates placement using visual component bounds when no indicators exist. Returns RuleResult if visual components found, null if no visual components (fall back to vacuous truth).