WithinTilemapBoundsRule
Summary
Section titled “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 returnsnull
forTileData
, 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 validTileMapLayer
for the rule to check against.
Properties
Section titled “Properties”success_message: String = “Placement is within map bounds”
Success message for valid placement.
failed_message: String = “Tried placing outside of valid map area”
Failure message for out-of-bounds placement.
no_indicators_message = “No tile collision indicators to check for within tilemap bounds.”
enable_debug_diagnostics: bool = false
Optional: enable extra per-indicator diagnostics during tile lookups (very verbose)
Methods
Section titled “Methods”func setup( p_gts: GridTargetingState ) -> Array[String]
func tear_down( )
func validate_placement( ) -> RuleResult
For each tilemap indicator, check the tilemap to see if the tile at its position is used on any layer or not.
func get_failing_indicators( p_indicators: Array[RuleCheckIndicator] ) -> Array[RuleCheckIndicator]
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 boundsCRITICAL: Overrides TileCheckRule.get_failing_indicators to avoid circular dependency where the base implementation checks indicator.valid, but indicator.valid depends on rule results
func _is_over_valid_tile( p_indicator: RuleCheckIndicator, p_target_map: TileMapLayer ) -> ValidationResults
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 forp_target_map
: Node2D - The target map to validate againstfunc _filter_critical_indicator_issues( issues: Array[String] ) -> Array[String]
Filters indicator issues, returning only those considered critical for bounds checking
func _is_critical_indicator_issue( issue: String ) -> bool
Determines if an issue string is critical (i.e., not cosmetic)
func _debug_diagnostic( message: String ) -> void
Emits gated diagnostics when debug diagnostics are enabled
Source
Section titled “Source”addons/grid_building/placement/placement_rules/template_rules/within_tilemap_bounds_rule.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.