TargetInformer
Summary
Section titled “Summary”Display UI for showing information about objects being targeted, manipulated, or built
TargetInformer provides a dynamic UI component that displays information based on the current game state. It responds to three different contexts with clear priority:
Priority System:
-
Manipulation (Highest Priority): Shows info for actively manipulated objects
-
Building: Shows info for building preview objects
-
Targeting (Lowest Priority): Shows info for hovered/targeted objects
Signal Flow:
-
GridTargetingState.target_changed→ Updates display on hover -
ManipulationState.active_target_node_changed→ Overrides targeting info -
BuildingState.preview_changed→ Shows building preview info
Usage:
var informer = TargetInformer.new()add_child(informer)informer.resolve_gb_dependencies(composition_container)# Now responds automatically to targeting/manipulation/building changesOverride _to_string() on displayed object nodes to show custom names
Properties
Section titled “Properties”Methods
Section titled “Methods”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.
p_container: GBCompositionContainer - Container with states and configurationfunc clear( )Clears all child controls from the info parent container.
func refresh( )Updates the target information display with current target data.
func setup( )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 track_manipulatable_target( )func _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 _on_manipulation_target_changed( p_target: Manipulatable )func _on_manipulation_started( p_data: ManipulationData )func _on_manipulation_finished( _p_data: ManipulationData )func _on_manipulation_canceled( _p_data: ManipulationData )func _on_target_tree_exiting( )func _on_building_preview_changed( p_preview: Node )func _on_mode_changed( p_mode: GBEnums.Mode )func _on_targeting_target_changed( _p_new: Node2D, _p_old: Node2D )Handle targeting state changes - shows info for any targeted object (hover).
Priority Logic: If manipulation is active (active_manipulatable != null) or building preview is active (preview != null), this handler returns early without updating the display. This ensures manipulation and building preview info takes precedence over targeting info.
Note: This listens to target_changed but displays target_root (the resolved logical root). This ensures we always show the correct root name even when the collision target changes.
_p_new: Node2D - Newly targeted collision object (unused, we read target_root instead)_p_old: Node2D - Previously targeted node (unused)
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.