TargetingService2D
AUTO-GENERATED FILE — DO NOT EDIT MANUALLY
Source: core/services/targeting_service_2d.gd
Version: 5.1
class_name: TargetingService2D
extends: RefCounted
Summary
TargetingService2D - Handles targeting and selection operations in Grid Building. Manages target acquisition, selection validation, and targeting systems.
Key concepts:
collider: the raw node currently hit/hovered (often aCollisionObject2D)current_target: the resolved logical root node (viaGBMetadataResolver) used by gameplay- manual targeting: when active, collision-driven updates are ignored and the caller controls the target
Signals
target_acquired- Emitted when a non-null resolved target becomes current.
target_lost- Emitted when the previously current target is cleared or replaced.
target_changed- Emitted whenever the resolved target changes (including becoming null).
selection_changed- Emitted when selection changes (separate from hover/targeting).
targeting_failed- Emitted when a targeting operation fails (currently used by placeholder methods).
positioner_changed- Emitted when the positioner used for targeting changes.
target_map_changed- Emitted when the target
TileMapLayerchanges.
- Emitted when the target
Exports
(none)
Methods
_init()- Creates a targeting service.
p_mode_service: if provided, targeting clears itself when mode switches to OFFp_owner_context: used by legacy consumers that need to resolve the owner rootp_grid_service: if provided, map/mapping data is sourced from it (instead of local fields)set_target_map()get_targeting_state()get_target_map()set_maps()get_maps()set_settings()get_settings()_on_grid_service_target_map_changed()_on_grid_service_maps_changed()update_from_collision()get_owner_root()_on_mode_changed()add_collision_exclusion()remove_collision_exclusion()get_collision_exclusions()get_current_target()get_selected_object()get_targeting_mode()set_targeting_mode()acquire_target()select_target()clear_targeting()_find_target_at_position()set_positioner()- Sets the positioner node used for targeting.
The positioner is typically a cursor-like node that represents where the user is aiming.
get_positioner()- Gets the positioner node used for targeting.
set_manual_target()- Sets a manual target for operations like manipulation.
When manual targeting is active, update_from_collision() becomes a no-op.
get_collider()is_manual_targeting_active()set_manual_targeting_active()get_snapshot()- Builds a snapshot of the current targeting state.
world_position: the position to sample for grid/hover data. When used by input, this should be the mouse position (world space).
The returned snapshot is safe to consume even when no map is configured.
clear_collision_exclusions()set_collider()- Updates the raw collider and resolves the logical target.
If p_collider is a CollisionObject2D, the service resolves a root gameplay node
via GBMetadataResolver.resolve_root_node. Otherwise the collider is used directly.
Emits target_lost / target_acquired / target_changed when the resolved target changes.
_is_redundant_collider_update()_disconnect_collider_signal()_on_collider_tree_exiting()_is_same_context_update()