Table of Contents

Class ValidPlacementTileRule

Namespace
GridPlacement.GDScript
Assembly
MoonBark.GridPlacement.GDScript.dll

A rule that validates a tile position based on a tilemap's custom data fields.\n\nThis 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.\n\nUsage: - Assign this rule to a PlacementContainer for context wide injection or to a ScenePlacementEntry for placeable specific rule evaluation - Set the expected_tile_custom_data dictionary 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.

class ValidPlacementTileRule extends TileCheckRule
ValidPlacementTileRule

Properties

expected_tile_custom_data

Expected custom data fields and values for valid tiles.

@export var expected_tile_custom_data = {}

settings

Settings for the valid placement tile rule. Defines custom messages for this rule's validation.

@export var settings: ValidPlacementRuleSettings

rule_settings

var rule_settings = _ensure_settings()

invalid_tile_count

var invalid_tile_count = _get_failing_indicators(indicators).size()

failing_indicators

var failing_indicators: Array[RuleCheckIndicator] = []

required_matches

var required_matches = 1

match_count

var match_count = 0

tile_pos

var tile_pos: Vector2i = _get_tile_position(map, p_indicator)

tile_data

var tile_data: TileData

matched

var matched = false

layer_count

Make sure the tile data has the custom_data requirements

var layer_count: int = map.get_layers_count()

issues

var issues: Array[String] = []

Methods

setup

func setup(p_gts : GridTargetingState) -> Array[String]:

Parameters

p_gts

Returns

validate_placement

func validate_placement() -> RuleResult:

Returns

tear_down

func tear_down() -> void:

Returns

does_tile_have_valid_data

func does_tile_have_valid_data(p_indicator: RuleCheckIndicator, p_maps: Array[TileMapLayer]) -> bool:

Parameters

p_indicator
p_maps

Returns