Grid Placement

RuleCheckIndicator

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: systems/placement/utilities/rule_check_indicator/rule_check_indicator.gd

Version: 5.1

class_name: RuleCheckIndicator extends: ShapeCast2D

Summary

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. [br][br]

Usage: 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]

[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]

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

See [code]project-architecture.md[/code] for system architecture and building flow documentation.

Signals

  • valid_changed
    • Emitted when validity status changes.

Exports

  • validity_sprite
    • Sprite showing tile validity status.
  • show_indicators
    • Whether to show the indicator visual sprites for players or not.
  • 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
  • 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
  • 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
  • valid
    • Whether the rules were validated for the area under the rule check indicator in the last test

Methods

  • _init()
  • _ready()
  • _physics_process()
    • 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.
  • resolve_gb_dependencies()
    • Resolve dependencies for the indicator
  • get_rules()
    • Returns the active tile check rules assigned to this indicator.
  • set_validation_context()
  • add_rule()
    • Adds rule to indicator and self to indicators array on the rule for all indicator validation checks.[br][br] [code]p_rule[/code]: [i]TileCheckRule[/i] - Rule to add to this indicator
  • _on_tree_entered_validate()
  • get_tile_position()
    • Gets the tile position that the indicator is currently positioned over.[br][br] [code]p_map[/code]: [i]TileMapLayer[/i] - TileMapLayer to convert global position to tile coordinates
  • clear()
    • Clears reference to self from all rule indicator arrays
  • validate_rules()
    • Tests each of the TileCheckRules against the indicator. Returns all failing rules.[br][br] [code]p_rules[/code]: [i]Array[TileCheckRule][/i] - Array of rules to validate against this indicator
  • _indicator_debug_enabled()
    • Updates the visual display of the indicator based on display settings. Sets texture and modulate color from the provided settings.[br][br] [code]p_display_settings[/code]: [i]IndicatorVisualSettings[/i] - Visual settings to apply to the indicator
  • _indicator_log_enabled()
    • Returns whether verbose indicator logs should be printed. This is stricter than _indicator_debug_enabled: requires explicit toggle or env var.
  • _update_visuals()
  • _update_current_display_settings()
    • Change the display settings of the indicator’s sprite based on validity and highest rule visual priority
  • _find_highest_rule_with_visual_settings()
    • Finds the rule with highest visual priority among failing rules. Returns the rule with the highest visual priority that has fail_visual_settings defined.[br][br] [code]p_rules[/code]: [i]Array[TileCheckRule][/i] - Array of rules to check for highest priority
  • _draw()
    • Draws debug visuals for collision contact points only.
  • get_debug_info()
    • Get current state information for debugging
  • validate_runtime()
  • trace_runtime_if_enabled()
    • Highly verbose logging of the RuleCheckIndicator during runtime. Will only process if GPLogger is set to Trace verbosity (very high!)
  • get_runtime_issues()
    • Gets issues with the indicator in the scene Runtime-time validations: checks useful during gameplay/runtime [return] Array[String] - Returns array of issues found
  • get_editor_issues()
    • Editor-time validations: checks useful in the editor / scene authoring Returns array of issues found
  • _on_debug_settings_changed()
  • _update_debug_cached_state()
  • update_validity_state()
    • Update the validity of the rule check indicator by validating all rules attached
  • force_validity_evaluation()
    • Immediately force shapecast update and a check for the validity of each rule given the new shapecast state
  • _on_valid_changed()
    • Callback when validity changes
  • _debug_setting_float_or()
    • Helpers to read debug tuning values from GBDebugSettings (if available).
  • _debug_setting_color_or()
    • Helpers to read debug tuning values from GBDebugSettings (if available).