ValidPlacementTileRule
Summary
Section titled “Summary”A rule that validates a tile position based on a tilemap’s custom data fields.
This rule checks if a tile at a potential placement position has all the required custom data fields and matching values defined in its expected_tile_custom_data dictionary. It’s used to ensure that a tile can only be placed on a specific type of ground, such as “walkable” or “buildable” tiles.
Usage:
- Assign this rule to a GBCompositionContainer for context wide injection or to a Placeable for placeable specific rule evaluation - Set the
expected_tile_custom_datadictionary to define the required key-value pairs (e.g.,\{ "type": "ground", "variant": "grass" \}). - The rule will fail if the tile at the indicator’s position does not contain all the required custom data or if any values do not match.
Properties
Section titled “Properties”expected_tile_custom_data = {}Expected custom data fields and values for valid tiles.
settings: ValidPlacementRuleSettingsSettings for the valid placement tile rule. Defines custom messages for this rule’s validation.
Methods
Section titled “Methods”func _init( p_expected_tile_data: Dictionary )func _ensure_settings( ) -> ValidPlacementRuleSettingsLazy initialization of settings - creates default settings if none are provided
func setup( p_gts: GridTargetingState ) -> Array[String]Creates tile indicators on matching layers to test that colliding tiles exist in shape spaces around the object to be placed
func validate_placement( ) -> RuleResultCheck each tile indicator of this test to ensure that they collide with the tilemap
func _get_failing_indicators( p_indicators: Array[RuleCheckIndicator] ) -> Array[RuleCheckIndicator]Runs the rule against an array of indicators and Returns the failing indicators
func tear_down( )Frees tile indicators created for this test when the building system no longer is using this rule
func _get_tile_position( map: Node2D, indicator: RuleCheckIndicator ) -> Vector2iHelper function to convert indicator position to tile coordinates
func _tile_has_matching_data( map: Node2D, tile_pos: Vector2i ) -> boolHelper function to check if a tile contains any matching custom data
func _post_setup_validation( ) -> Array[String]
Source
Section titled “Source”addons/grid_building/placement/placement_rules/template_rules/valid_placement_tile_rule.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.