Class WithinTilemapBoundsRule
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
A rule that validates placement is within the boundaries of a tilemap.\n\nThis 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.\n\nBehavior: - 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.\n\nUsage: - Attach this rule to a PlacementContainer 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.
class WithinTilemapBoundsRule extends TileCheckRule
Fields
NON_CRITICAL_ISSUE_KEYWORDS
Issue keywords considered non-critical for bounds checking (cosmetic/setup)
const NON_CRITICAL_ISSUE_KEYWORDS: Array[String] = [
Properties
success_message
Success message for valid placement.
@export var success_message: String = "Placement is within map bounds"
failed_message
Failure message for out-of-bounds placement.
@export var failed_message: String = "Tried placing outside of valid map area"
no_indicators_message
@export var no_indicators_message = "No tile collision indicators to check for within tilemap bounds."
enable_debug_diagnostics
Optional: enable extra per-indicator diagnostics during tile lookups (very verbose)
@export var enable_debug_diagnostics: bool = false
failing_indicators
var failing_indicators: Array[RuleCheckIndicator] = []
failing_indicators
var failing_indicators: Array[RuleCheckIndicator] = []
target_map
var target_map: TileMapLayer = _grid_targeting_state.target_map
results
var results: ValidationResults = ValidationResults.new()
results
var results: ValidationResults = ValidationResults.new()
indicator_issues
var indicator_issues: Array[String] = p_indicator.get_runtime_issues()
critical_issues
var critical_issues: Array[String] = _filter_critical_indicator_issues(indicator_issues)
local_pos
var local_pos: Vector2 = p_target_map.to_local(p_indicator.global_position)
tile_under
var tile_under: Vector2i = p_target_map.local_to_map(local_pos)
cell_data
var cell_data: TileData = p_target_map.get_cell_tile_data(tile_under)
critical
var critical: Array[String] = []
Methods
setup
func setup(p_gts : GridTargetingState) -> Array[String]:
Parameters
p_gts
Returns
tear_down
func tear_down() -> void:
Returns
validate_placement
func validate_placement() -> RuleResult:
Returns
get_failing_indicators
func get_failing_indicators(p_indicators : Array[RuleCheckIndicator]) -> Array[RuleCheckIndicator]:
Parameters
p_indicators