Grid Placement

TargetInformer

AUTO-GENERATED FILE — DO NOT EDIT MANUALLY

Source: ui/target_informer/target_informer.gd

Version: 5.1

class_name: TargetInformer extends: GBControl

Summary

Display UI for showing information about objects being targeted, manipulated, or built [br][br] TargetInformer is a view-only component that reads from state sources and displays information based on the current game state with a clear priority system:[br] [br] [b]Priority System (Highest to Lowest):[/b][br]

  1. [b]Manipulation[/b]: Actively manipulated objects (from ManipulationState.active_manipulatable)[br]
  2. [b]Building[/b]: Building preview objects (from BuildingState.preview)[br]
  3. [b]Targeting[/b]: Hovered/targeted objects (from GridTargetingState.target)[br] [br] [b]Design:[/b] TargetInformer reads from authoritative state sources rather than maintaining its own target property. This ensures the display is always synchronized with game logic.[br] [br] [b]Usage:[/b][br] [codeblock] var informer = TargetInformer.new() add_child(informer) informer.resolve_gb_dependencies(composition_container)

Now automatically displays the highest-priority target

[/codeblock] [br] Override [code]_to_string()[/code] on displayed object nodes to show custom names.

Signals

(none)

Exports

  • info_parent

Methods

  • get_display_target()
    • Returns the current display target based on priority:[br]
  1. Manipulation (highest) → 2. Building → 3. Targeting (lowest)[br] [return] The highest-priority target node, or null if no target available
  • _ready()
    • Initialize the target informer display when ready.
  • resolve_gb_dependencies()
    • Resolve dependencies from the composition container.[br][br] Connects to state change signals to trigger display updates. [code]p_container[/code]: [i]GBCompositionContainer[/i] - Container with states and configuration
  • clear()
    • Clears all child controls from the info parent container.
  • refresh()
    • Updates the display based on the current display target.[br] If the target changed, calls setup(). Otherwise updates position label every frame.
  • setup_for_target()
    • Builds UI labels for the given target node. Clears existing labels and creates new ones based on node type.
  • add_info_label()
    • Adds an information label to the info parent container. Creates a new label with the specified text and adds it to the UI.[br][br] [code]p_text[/code]: [i]String[/i] - Text to display in the label
  • _format_position()
    • Formats a node’s global position for display. Uses the position format and decimal precision from settings.[br][br] [code]p_target[/code]: [i]Node[/i] - Node to format position for (must be Node2D or Node3D)
  • _disconnect_all_signals()
    • Safely disconnects all previously connected state change signals. Used before reconnecting during dependency re-initialization to prevent duplicate signal errors.
  • _on_state_changed()
    • Unified signal handler for all state changes.[br] Called when any of the three state sources (manipulation, building, targeting) change. This triggers a refresh to update the display with the new highest-priority target.[br] Accepts variadic arguments to handle signals with different parameter counts.
  • _on_mode_changed()
  • _schedule_refresh()
  • _do_scheduled_refresh()