GridTargetingSystem
Summary
Section titled “Summary”Orchestrates grid targeting dependencies (state, settings, path manager, position mover).
Provides a single injection point for GridTargeting/Settings/PathManager, owns the shared AStar grid manager, and exposes runtime APIs for other systems (placement, manipulation) to validate targeting readiness or request tile movements. Scene nodes such as GridPositioner2D focus on visuals/input, while this system keeps configuration, validation, and helper delegation centralized.
Signals
Section titled “Signals”signal astar_grid_changed( astar_grid: AStarGrid2D )
Emitted when the AStarGrid2D used by the Grid Targeting System is created or changes
Properties
Section titled “Properties”target_tile: Vector2
The tile location where the mouse is currently hovering over represented as X / Y values of the _targeting_state.target_map
ui_mouse_handled: bool = false
Whether the mouse input was consumed by GUI already or not (renamed from mouse_handled)
astar_grid: AStarGrid2D = null
Contains the current values for targeting _targeting_state related properties
Methods
Section titled “Methods”static func create_with_injection( p_parent: Node, container: GBCompositionContainer ) -> GridTargetingSystem
Creates a GridTargetingSystem with dependency injection from container.
func get_runtime_issues( ) -> Array[String]
Validates that all required dependencies are properly set. Returns list of validation issues (empty if valid).
func get_state( ) -> GridTargetingState
Compatibility accessor for older tests expecting get_state(). Returns the underlying GridTargetingState used by this system.
func _input( event: InputEvent ) -> void
Move the positioner to the center of the mouse tile over where the mouse is
:::note[Note] Positioner updates are now handled by GridPositioner2D :::
func resolve_gb_dependencies( p_container: GBCompositionContainer ) -> void
func move_node_to_closest_valid_tile( p_target_tile: Vector2i, p_positioner: Node2D, p_source: Node2D ) -> Error
Move the positioner to adjust the shown position of any visual _targeting_settings elements. If limit_to_adjacent setting is on, the closest valid target will be limited by the p_source position and the max_tiles_distance.
p_target_tile
: Vector2i - Desired tile location to move top_positioner
: Node2D - Node to move to the target positionp_source
: Node2D - Source node for distance calculations when limit_to_adjacent is enabledfunc move_to_tile( p_node: Node2D, p_tile: Vector2 ) -> Error
Moves a target node to the center snapped position of a p_tile on the _targeting_state.target_map.
p_node
: Node2D - Node to move to the tile positionp_tile
: Vector2 - Tile coordinates to move tofunc get_tile_from_global_position( p_global_position: Vector2, p_map: Node2D )
Returns the tile on the p_tile_map where the mouse is currently hovering over.
p_global_position
: Vector2 - Global position to convert to tile coordinatesp_map
: Node2D - TileMap or TileMapLayer to use for coordinate conversionfunc update_astar_grid_2d( p_astar: AStarGrid2D, p_targeting_settings: GridTargetingSettings )
Updates an AStarGrid2D according to a set of GridTargetingSettings.
p_astar
: AStarGrid2D - AStar grid to configurep_targeting_settings
: GridTargetingSettings - Settings to apply to the AStar gridfunc _on_validator_valid_changed( is_valid: bool )
func _on_mode_changed( p_mode: GBEnums.Mode )
func _subscribe_targeting_settings( )
Subscribe to all needed signals
func _on_settings_changed( ) -> void
func validate_and_log_issues( ) -> Array[String]
Public manual validation entry point for host projects. Runs get_runtime_issues() and logs issues without relying on timed warnings. Returns the list of issues (empty when valid).
func _unsubscribe_targeting_settings( )
func _get_target_map( ) -> TileMapLayer
func _are_dependencies_resolved( ) -> bool
Private helper to check if all required dependencies are resolved.
return
: bool - True if dependencies are available, false otherwisefunc validate_ready( ) -> bool
func get_targeting_issues( ) -> Array[String]
Gets issues that would prevent the targeting_system from being able to target. This should be called after grid targeting state properties have all been defined
Source
Section titled “Source”addons/grid_building/systems/grid_targeting/grid_targeting_system.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.