TargetInformer
Summary
Section titled “Summary”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):
-
Manipulation: Actively manipulated objects (from ManipulationState.active_manipulatable)
-
Building: Building preview objects (from BuildingState.preview)
-
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 targetOverride _to_string() on displayed object nodes to show custom names.
Properties
Section titled “Properties”info_parent: Control
Methods
Section titled “Methods”func get_display_target( ) -> NodeTracks the last display target to detect changes (prevents redundant setup calls)
Returns the current display target based on priority:
- Manipulation (highest) → 2. Building → 3. Targeting (lowest)
Returns: The highest-priority target node, or null if no target available
func _ready( ) -> voidInitialize the target informer display when ready.
func _process( delta: float ) -> voidUpdate the target information display every frame.
func resolve_gb_dependencies( p_container: GBCompositionContainer ) -> voidResolve dependencies from the composition container.
Connects to state change signals to trigger display updates.
p_container: GBCompositionContainer - Container with states and configurationfunc 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 ) -> LabelAdds 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 labelfunc _format_position( p_target: Node ) -> StringFormats 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( ) -> voidSafely 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 )
Source
Section titled “Source”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.