Table of Contents

Class RuleCheckIndicator

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

Tile indicator showing placement validity based on rules and collisions.\n\nDisplays visual feedback for tile validity during building preview by running all assigned TileCheckRules and updating its visuals accordingly. Used by IndicatorManager and PlacementValidator as part of the validation pipeline. [br][br]\n\nUsage: It is recommended to set the TargetPosition to Vector2(0,0) so that the indicator's position aligns with the tile being evaluated. [br][br]\n\n[b]IMPORTANT FOR ISOMETRIC GAMES:[/b] This ShapeCast2D should use [ConvexPolygonShape2D] with explicit diamond points, NOT [RectangleShape2D] with skew transformation. When the parent [ManipulationParent] rotates (e.g., 90° during manipulation), skewed rectangles create visual distortion due to compound transforms (skew + rotation). Polygon shapes rotate uniformly without perspective changes. [br][br]\n\nFor detailed explanation and examples, see: [code]docs/v5-0-0/guides/isometric_implementation.mdx[/code][br][br]\n\nSee [code]project-architecture.md[/code] for system architecture and building flow documentation.

class RuleCheckIndicator extends res://addons/grid_building/base/gb_cached_shape_cast_2d.gd
RuleCheckIndicator

Fields

LogLevel

const LogLevel = GBDebugSettings.LogLevel

Properties

validity_sprite

Sprite showing tile validity status.

@export var validity_sprite: Sprite2D = null

show_indicators

Whether to show the indicator visual sprites for players or not.

@export var show_indicators: bool = true :

valid_settings

Default display settings for when the rule check indicator is marked valid. [br] If unset, will default at runtime. However you should define a valid IndicatorVisualSettings for production games

@export var valid_settings: IndicatorVisualSettings

invalid_settings

Default display settings for when the rule check indicator is marked invalid. [br] If unset, will default at runtime. However you should define a valid IndicatorVisualSettings for production games

@export var invalid_settings: IndicatorVisualSettings

rules

The rules to validate for whether this tile is valid for placement or not All rules must validate true to be valid. Otherwise, failed status will be shown\n\nFor production, you do not set them in the template. You load them through the PlacementContainer. The @export option is only provided here for debug testing purposes in editor.

@export var rules: Array[TileCheckRule] = [] :

current_display_settings

var current_display_settings: IndicatorVisualSettings = null :

valid

Whether the rules were validated for the area under the rule check indicator in the last test

@export var valid: bool = false :

shape_size

var shape_size = (shape.get_rect().size if shape else Vector2.ZERO)

map_local_pos

var map_local_pos: Vector2 = p_map.to_local(global_position)

map_tile

var map_tile: Vector2i = p_map.local_to_map(map_local_pos)

failing_checker

var failing_checker: Callable = func(rule: TileCheckRule) -> Array:

settings

var settings = _logger.get_debug_settings() if _logger.has_method("get_debug_settings") else null

settings

var settings = _logger.get_debug_settings() if _logger.has_method("get_debug_settings") else null

texture_name

var texture_name = p_display_settings.texture.resource_name if p_display_settings.texture else "null"

is_valid

var is_valid = p_is_valid if p_is_valid != null else valid

selected_rule

var selected_rule: TileCheckRule = null

selected_priority

var selected_priority = null

shape_bounds

var shape_bounds = shape.get_rect() if shape else Rect2(0, 0, 16, 16)

tile_size

var tile_size = min(shape_bounds.size.x, shape_bounds.size.y)

collision_min_radius

var collision_min_radius = _debug_setting_float_or(2.0, "indicator_collision_point_min_radius")

collision_scale

var collision_scale = _debug_setting_float_or(0.15, "indicator_collision_point_scale")

connection_min_width

var connection_min_width = _debug_setting_float_or(1.0, "indicator_connection_line_min_width")

connection_scale

var connection_scale = _debug_setting_float_or(0.05, "indicator_connection_line_scale")

collision_point_radius

var collision_point_radius = max(collision_min_radius, tile_size * collision_scale)

connection_line_width

var connection_line_width = max(connection_min_width, tile_size * connection_scale)

contact

var contact = collision_result[i]

local_contact_point

var local_contact_point: Vector2 = to_local(contact.point)

connection_color

var connection_color = _debug_setting_color_or(Color.ORANGE, "indicator_connection_line_color")

collision_color

var collision_color = _debug_setting_color_or(Color.RED, "indicator_collision_point_color")

outline_color

var outline_color = _debug_setting_color_or(Color.WHITE, "indicator_outline_color")

marker_radius

var marker_radius = max(1.0, collision_point_radius * 0.3)

text_offset

var text_offset = Vector2(-collision_point_radius * 0.5, collision_point_radius * 0.5)

issues

var issues: Array[String] = []

issues

var issues: Array[String] = []

issues

var issues: Array[String] = []

issues

var issues: Array[String] = []

settings

var settings = _logger.get_debug_settings() if _logger.has_method("get_debug_settings") else null

frame_signal

var frame_signal: Signal

settings

var settings = _logger.get_debug_settings() if _logger.has_method("get_debug_settings") else null

val

var val = settings.get(getter_name)

settings

var settings = _logger.get_debug_settings() if _logger.has_method("get_debug_settings") else null

val

var val = settings.get(getter_name)

Methods

resolve_gb_dependencies

func resolve_gb_dependencies(p_container : PlacementContainer) -> void:

Parameters

p_container

Returns

get_rules

func get_rules() -> Array[TileCheckRule]:

Returns

add_rule

func add_rule(p_rule : TileCheckRule) -> void:

Parameters

p_rule

Returns

get_tile_position

func get_tile_position(p_map : TileMapLayer) -> Vector2i:

Parameters

p_map

Returns

clear

func clear() -> void:

Returns

validate_rules

func validate_rules(p_rules : Array[TileCheckRule]) -> Array[TileCheckRule]:

Parameters

p_rules

Returns

get_debug_info

func get_debug_info() -> Dictionary:

Returns

validate_runtime

func validate_runtime() -> bool:

Returns

trace_runtime_if_enabled

func trace_runtime_if_enabled() -> void:

Returns

get_runtime_issues

func get_runtime_issues() -> Array[String]:

Returns

get_editor_issues

func get_editor_issues() -> Array[String]:

Returns

update_validity_state

func update_validity_state() -> bool:

Returns

force_validity_evaluation

func force_validity_evaluation() -> bool:

Returns

force_validity_evaluation_with_sync

func force_validity_evaluation_with_sync() -> bool:

Returns

Events

valid_changed

Emitted when validity status changes.

signal valid_changed(is_valid : bool)