Controls the on-grid cursor used by building/interaction systems. Responsibilities:
- Recenter according to GridTargetingSettings policy when input/mode is enabled
- Follow mouse/keyboard input to update on-grid position
- STRICTLY for tile center targeting
- does NOT handle rotation or manipulation Targeting separation: Target acquisition/collision detection is handled by dedicated components (e.g., TargetingShapeCast2D). GridPositioner2D no longer depends on or manages any shapecast component. Manipulation separation: Object rotation, flipping, and manipulation are handled by ManipulationParent. GridPositioner2D focuses solely on positioning the targeting cursor at tile centers. Dependency Injection:
resolve_placement_dependencies(container)is the standard method called by PlacementInjectorSystem to inject dependencies. This is the primary integration pattern for runtime use.set_dependencies(...)is an internal helper for testing and advanced use cases.
Source: addons/grid_placement/systems/grid_targeting/grid_positioner/grid_positioner_2d.gd
Syntax
class GridPositioner2D extends Node2DMembers
| Name | Kind | Summary |
|---|---|---|
session | Property | Host pattern (canonical): the [PlacementSession] this positioner pulls its dependencies from. When set, [method _ready] self-configures and registers with the nearest [GridPlacementHost] for input routing. Leave null to use the deprecated injector pattern. |
LOG_PREFIX | Field | |
set_targeting_state | Method | |
cursor_source | Property | Injected cursor-source callable. Returns a [Vector2] screen position. If the callable returns [code]null[/code], or if [member cursor_source] is not set, falls back to the real viewport mouse position. Tests inject a callable that returns a fixed Vector2 for deterministic positioning. Usage in tests: positioner.cursor_source = func(): return Vector2(100, 100) |
input_processing_enabled | Property | Public flag & API for enabling/disabling input processing (used by tests) |
set_input_processing_enabled | Method | |
is_input_processing_enabled | Method | |
is_input_ready | Method | |
are_dependencies_ready | Method | |
resolve_placement_dependencies | Method | |
move_to_viewport_center_tile | Method | |
move_to_cursor_center_tile | Method | |
remove_self_as_positioner | Method | |
update_visibility | Method | |
should_be_visible | Method | |
set_dependencies | Method | |
get_runtime_issues | Method | |
validate_dependencies | Method | |
get_visual_node | Method | |
is_visual_visible | Method | |
is_positioner_active | Method | |
are_dependencies_resolved | Method | |
to_diagnostic_string | Method |