ValidPlacementTileRule

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

A rule that validates a tile position based on a tilemap’s custom data fields.

Source File: addons/grid_building/placement/placement_rules/template_rules/valid_placement_tile_rule.gd

Extends: TileCheckRule

Exported Properties

  • Property: expected_tile_custom_data = {} - Expected custom data fields and values for valid tiles.
  • Property: settings : [ValidPlacementRuleSettings](./valid-placement-rule-settings/) - Settings for the valid placement tile rule. Defines custom messages for this rule’s validation.

Public Methods

setup

1
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


validate_placement

1
validate_placement() -> RuleResult

Check each tile indicator of this test to ensure that they collide with the tilemap


tear_down

1
tear_down()

Frees tile indicators created for this test when the building system no longer is using this rule


does_tile_have_valid_data

1
2
3
4
does_tile_have_valid_data(
    p_indicator: RuleCheckIndicator,
    p_maps: Array[TileMapLayer]
) -> bool

Validates if tile data contains all expected custom data across provided maps. Returns true only if all expected custom data keys match at least one layer in the tile data.

p_indicator: RuleCheckIndicator - The indicator object marking the tile position to check

p_maps: Array[TileMapLayer] - Array of TileMapLayer or TileMap nodes to check against


Private Methods

_init

1
_init(p_expected_tile_data : Dictionary = {})

Flags: private


_ensure_settings

1
_ensure_settings() -> ValidPlacementRuleSettings

Flags: private

Lazy initialization of settings - creates default settings if none are provided


_get_failing_indicators

1
2
3
_get_failing_indicators(
    p_indicators : Array[RuleCheckIndicator]
) -> Array[RuleCheckIndicator]

Flags: private

Runs the rule against an array of indicators and Returns the failing indicators


_get_tile_position

1
2
3
4
_get_tile_position(
    map: Node2D,
    indicator: RuleCheckIndicator
) -> Vector2i

Flags: private

Helper function to convert indicator position to tile coordinates


_tile_has_matching_data

1
2
3
4
_tile_has_matching_data(
    map: Node2D,
    tile_pos: Vector2i
) -> bool

Flags: private

Helper function to check if a tile contains any matching custom data


_test_tile_data_for_all_matches

1
2
3
4
_test_tile_data_for_all_matches(
    p_tile_data : TileData,
    p_required_custom_data : Dictionary
) -> bool

Flags: private

Checks if the tile data meets all required custom data matches


_post_setup_validation

1
_post_setup_validation() -> Array[String]

Flags: private