DragManager
Summary
Section titled “Summary”Self-contained drag manager for tile-based drag operations.
Reads confirm_build input action directly and monitors GridTargetingState for tile changes. When both conditions are met (physics frame + new tile), calls BuildingSystem.try_build().
Architecture (v5.0.0): - One-way dependency: DragManager → BuildingSystem (calls try_build API) - BuildingSystem has NO knowledge of DragManager - Reads input directly via _input() to monitor confirm_build action state - Monitors GridTargetingState tile changes in _physics_process() - Physics-gated to prevent multiple builds per frame - Calls BuildingSystem.try_build() when conditions met
Usage: - Add DragManager as a child of your World/Systems node in the scene - Call resolve_gb_dependencies(container) to inject dependencies - DragManager automatically handles input, drag lifecycle, and building
Constants
Section titled “Constants”const DEFAULT_NAME = “DragManager”
Prevents multiple signal emissions in same physics frame. Tracks the last physics frame where targeting_new_tile was emitted to gate rapid signals. See: CHANGES/2025-10-02-drag-building-race-condition.md
Properties
Section titled “Properties”drag_data: DragPathData = null
Methods
Section titled “Methods”func _init( p_name: String ) -> void
func _ready( )
func set_test_mode( enabled: bool ) -> void
Public API for tests to manually control drag lifecycle. Disables input processing and allows manual drag control.
func reset_physics_frame_gate( ) -> void
Public API for tests: Reset the physics frame gate to allow next build. This simulates advancing to a new physics frame without actually waiting. Tests can call this between movements to clear the per-frame gate.
func start_drag( ) -> DragPathData
Public API: Start drag operation and return drag data. Returns: DragPathData instance, or null if drag cannot start
func stop_drag( ) -> void
Public API: Stop drag operation.
static func format_drag_state( drag_data: DragPathData ) -> String
DRY diagnostic helper: Format drag state for debugging
drag_data
: The DragPathData instance to format Returns: Formatted string with drag state informationfunc _input( event: InputEvent ) -> void
Reads confirm_build input action to start/stop drag operations. Uses _input() instead of _unhandled_input() to read raw input state regardless of handling.
func update_drag_state( delta: float ) -> void
Public API: Update drag state and check for tile changes. Core drag update logic extracted for testability. Called automatically by _physics_process() during normal gameplay. Tests can call this directly to simulate drag updates without physics timing.
delta
: Time elapsed since last update in secondsfunc _physics_process( delta: float ) -> void
Synchronizes drag detection with physics frame updates to prevent race conditions. Changed from _process() to _physics_process() to ensure drag events align with collision detection updates, preventing multiple builds in same physics frame. See: CHANGES/2025-10-02-drag-building-race-condition.md
func resolve_gb_dependencies( p_container: GBCompositionContainer ) -> void
func is_dragging( ) -> bool
func _start_drag( ) -> DragPathData
Internal: Start drag operation and return drag data. Returns: DragPathData instance, or null if drag cannot start
func _stop_drag( ) -> void
func _can_continue_dragging( ) -> bool
Source
Section titled “Source”addons/grid_building/systems/building/components/drag_manager.gd
This API reference is automatically generated from the plugin source code. For implementation examples and usage guides, see the guides section.