Class AdjacencyRequiredRule
- Namespace
- GridPlacement.GDScript
- Assembly
- MoonBark.GridPlacement.GDScript.dll
Rule that requires a tile paint action to be adjacent to a matching neighbor.
class AdjacencyRequiredRule extends TilePaintRule
AdjacencyRequiredRule
Properties
match_terrain_name
The terrain name to match against neighbors. If empty, matches the current terrain being placed.
@export var match_terrain_name: StringName = &""
require_horizontal
If true, requires a horizontal neighbor (left or right).
@export var require_horizontal: bool = false
require_vertical
If true, requires a vertical neighbor (up or down).
@export var require_vertical: bool = false
min_neighbors
Minimum number of matching neighbors required. If require_horizontal is true, this applies to the horizontal set. If require_vertical is true, this applies to the vertical set. If BOTH are true, the tile must have at least one neighbor in BOTH directions (forming a 2x2 corner/segment).
@export_range(1, 8) var min_neighbors: int = 1
include_diagonal
Whether to include diagonal neighbors in the search.
@export var include_diagonal: bool = false
error_message
Descriptive error message to show when validation fails.
@export var error_message: String = "This tile must be placed adjacent to a matching neighbor."
terrain_to_match
var terrain_to_match = match_terrain_name
horiz_count
var horiz_count = AdjacencyEvaluator.count_matching_neighbors_in_dirs(
vert_count
var vert_count = AdjacencyEvaluator.count_matching_neighbors_in_dirs(
diag_count
var diag_count = 0
total_count
var total_count = horiz_count + vert_count + diag_count
Methods
validate_cell
func validate_cell(p_context: PlacementValidationContext) -> Array[String]:
Parameters
p_context