Skip to content

TargetInformer

Display UI for showing information about objects being targeted, manipulated, or built

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:

Priority System (Highest to Lowest):

  1. Manipulation: Actively manipulated objects (from ManipulationState.active_manipulatable)

  2. Building: Building preview objects (from BuildingState.preview)

  3. Targeting: Hovered/targeted objects (from GridTargetingState.target)

Design: TargetInformer reads from authoritative state sources rather than maintaining its own target property. This ensures the display is always synchronized with game logic.

Usage:

var informer = TargetInformer.new()
add_child(informer)
informer.resolve_gb_dependencies(composition_container)
# Now automatically displays the highest-priority target

Override _to_string() on displayed object nodes to show custom names.

info_parent: Control
func get_display_target( ) -> Node

Tracks the last display target to detect changes (prevents redundant setup calls)

Returns the current display target based on priority:

  1. Manipulation (highest) → 2. Building → 3. Targeting (lowest)

Returns: The highest-priority target node, or null if no target available

func _ready( ) -> void

Initialize the target informer display when ready.

func _process( delta: float ) -> void

Update the target information display every frame.

func resolve_gb_dependencies( p_container: GBCompositionContainer ) -> void

Resolve dependencies from the composition container.

Connects to state change signals to trigger display updates. p_container: GBCompositionContainer - Container with states and configuration

func clear( )

Clears all child controls from the info parent container.

func refresh( )

Updates the display based on the current display target.

If the target changed, calls setup(). Otherwise updates position label every frame.

func setup_for_target( p_target: Node )

Builds UI labels for the given target node. Clears existing labels and creates new ones based on node type.

func add_info_label( p_text: String ) -> Label

Adds an information label to the info parent container. Creates a new label with the specified text and adds it to the UI.

p_text: String - Text to display in the label

func _format_position( p_target: Node ) -> String

Formats a node’s global position for display. Uses the position format and decimal precision from settings.

p_target: Node - Node to format position for (must be Node2D or Node3D)

func _disconnect_all_signals( ) -> void

Safely disconnects all previously connected state change signals. Used before reconnecting during dependency re-initialization to prevent duplicate signal errors.

func _on_state_changed( null: _unused1 =, null: _unused2 = )

Unified signal handler for all state changes.

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.

Accepts variadic arguments to handle signals with different parameter counts.

func _on_mode_changed( p_mode: GBEnums.Mode )

addons/grid_building/ui/target_informer/target_informer.gd


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