Skip to content

RuleCheckIndicator

Tile indicator showing placement validity based on rules and collisions.

Displays 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.

Usage: It is recommended to set the TargetPosition to Vector2(0,0) so that the indicator’s position aligns with the tile being evaluated.

IMPORTANT FOR ISOMETRIC GAMES: 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.

For detailed explanation and examples, see: docs/v5-0/guides/isometric_implementation.mdx

See project-architecture.md for system architecture and building flow documentation.

signal valid_changed( is_valid: bool )

Emitted when validity status changes.

validity_sprite: Sprite2D = null

Sprite showing tile validity status.

show_indicators: bool = true

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

valid_settings: IndicatorVisualSettings

Default display settings for when the rule check indicator is marked valid.

If unset, will default at runtime. However you should define a valid IndicatorVisualSettings for production games

invalid_settings: IndicatorVisualSettings

Default display settings for when the rule check indicator is marked invalid.

If unset, will default at runtime. However you should define a valid IndicatorVisualSettings for production games

rules: Array[TileCheckRule] = []

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

current_display_settings: IndicatorVisualSettings = null
valid: bool = false

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

func _init( p_rules: Array[TileCheckRule] )
func _ready( )
func _physics_process( _delta: float ) -> void

Per-frame rule processing; indicators always re-evaluate rules every physics frame. This keeps visual feedback immediately responsive to dynamic collision or rule state changes.

func resolve_gb_dependencies( p_container: GBCompositionContainer ) -> void

Resolve dependencies for the indicator

func get_rules( ) -> Array[TileCheckRule]

Returns the active tile check rules assigned to this indicator.

func add_rule( p_rule: TileCheckRule )

Adds rule to indicator and self to indicators array on the rule for all indicator validation checks.

p_rule: TileCheckRule - Rule to add to this indicator

func _on_tree_entered_validate( )
func get_tile_position( p_map: TileMapLayer ) -> Vector2i

Gets the tile position that the indicator is currently positioned over.

p_map: TileMapLayer - TileMapLayer to convert global position to tile coordinates

func clear( )

Clears reference to self from all rule indicator arrays

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

Tests each of the TileCheckRules against the indicator. Returns all failing rules.

p_rules: Array[TileCheckRule] - Array of rules to validate against this indicator

func _indicator_debug_enabled( ) -> bool

Updates the visual display of the indicator based on display settings. Sets texture and modulate color from the provided settings.

p_display_settings: IndicatorVisualSettings - Visual settings to apply to the indicator

func _indicator_log_enabled( ) -> bool

Returns whether verbose indicator logs should be printed. This is stricter than _indicator_debug_enabled: requires explicit toggle or env var.

func _update_visuals( p_display_settings: IndicatorVisualSettings ) -> Sprite2D
func _update_current_display_settings( p_display_rules: Array[TileCheckRule], null: p_is_valid = )

Change the display settings of the indicator’s sprite based on validity and highest rule visual priority

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

Finds the rule with highest visual priority among failing rules. Returns the rule with the highest visual priority that has fail_visual_settings defined.

p_rules: Array[TileCheckRule] - Array of rules to check for highest priority

func _draw( )

Draws debug visuals for collision contact points only.

func get_debug_info( ) -> Dictionary

Get current state information for debugging

func validate_runtime( ) -> bool
func trace_runtime_if_enabled( ) -> void

Highly verbose logging of the RuleCheckIndicator during runtime. Will only process if GBLogger is set to Trace verbosity (very high!)

func get_runtime_issues( ) -> Array[String]

Gets issues with the indicator in the scene Runtime-time validations: checks useful during gameplay/runtime Returns: Array[String] - Returns array of issues found

func get_editor_issues( ) -> Array[String]

Editor-time validations: checks useful in the editor / scene authoring Returns array of issues found

func _on_debug_settings_changed( ) -> void
func _update_debug_cached_state( ) -> void
func update_validity_state( ) -> bool

Update the validity of the rule check indicator by validating all rules attached

func force_validity_evaluation( ) -> bool

Immediately force shapecast update and a check for the validity of each rule given the new shapecast state

func _on_valid_changed( is_valid: bool )

Callback when validity changes

func _debug_setting_float_or( default_value: float, getter_name: String ) -> float

Helpers to read debug tuning values from GBDebugSettings (if available).

func _debug_setting_color_or( default_value: Color, getter_name: String ) -> Color

Helpers to read debug tuning values from GBDebugSettings (if available).

addons/grid_building/placement/rule_check_indicator/rule_check_indicator.gd


This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.