DragManager

AUTO-GENERATED FILE – DO NOT EDIT MANUALLY

Self-contained drag manager for tile-based drag operations.

Source File: addons/grid_building/systems/building/components/drag_manager.gd

Extends: GBSystemsComponent

Properties

  • Property: drag_data: [DragPathData](./drag-path-data/) = null

Private Properties

  • Property: _targeting_state: [GridTargetingState](./grid-targeting-state/) (private)

  • Property: _building_system: [BuildingSystem](./building-system/) (private)

  • Property: _logger: [GBLogger](./gb-logger/) (private)

  • Property: _actions: [GBActions](./gb-actions/) (private)

  • Property: _last_signal_physics_frame: int = -1 (private)

    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

Constants

  • Constant: DEFAULT_NAME = "DragManager"

Public Methods

set_test_mode

1
set_test_mode(enabled: bool) -> void

Public API for tests to manually control drag lifecycle. Disables input processing and allows manual drag control.


reset_physics_frame_gate

1
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.


start_drag

1
start_drag() -> DragPathData

Public API: Start drag operation and return drag data. [return] DragPathData instance, or null if drag cannot start


stop_drag

1
stop_drag() -> void

Public API: Stop drag operation.


format_drag_state

1
format_drag_state(drag_data: DragPathData) -> String

Flags: static

DRY diagnostic helper: Format drag state for debugging drag_data The DragPathData instance to format [return] Formatted string with drag state information


update_drag_state

1
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 seconds


resolve_gb_dependencies

1
resolve_gb_dependencies(p_container: GBCompositionContainer) -> void

is_dragging

1
is_dragging() -> bool

Private Methods

_init

1
_init(p_name: String = DEFAULT_NAME) -> void

Flags: private


_ready

1
_ready()

Flags: private


_input

1
_input(event: InputEvent) -> void

Flags: private

Reads confirm_build input action to start/stop drag operations. Uses _input() instead of _unhandled_input() to read raw input state regardless of handling.


_should_update_drag

1
_should_update_drag() -> bool

Flags: private

Returns true if drag state should be updated


_log_drag_update_start

1
2
3
4
_log_drag_update_start(
    old_tile: Vector2i,
    positioner_pos: Vector2
) -> void

Flags: private

Logs the start of a drag update


_log_drag_cannot_continue

1
_log_drag_cannot_continue() -> void

Flags: private

Logs that drag cannot continue


_log_drag_update_result

1
_log_drag_update_result(old_tile: Vector2i) -> void

Flags: private

Logs the result of a drag update


_handle_tile_change

1
_handle_tile_change(old_tile: Vector2i) -> void

Flags: private

Handles a tile change during drag


_should_process_tile_change

1
_should_process_tile_change() -> bool

Flags: private

Returns true if tile change should be processed


_prevent_duplicate_build_attempts

1
_prevent_duplicate_build_attempts() -> void

Flags: private

Prevents consecutive attempts on the same tile


_trigger_build_if_ready

1
_trigger_build_if_ready() -> void

Flags: private

Triggers build if all conditions are met


_is_in_build_mode

1
_is_in_build_mode() -> bool

Flags: private

Returns true if BuildingSystem is in BUILD mode with active preview


_has_active_preview

1
_has_active_preview() -> bool

Flags: private

Returns true if there is an active preview


_log_no_building_system

1
_log_no_building_system() -> void

Flags: private

Logs that BuildingSystem reference is missing


_log_not_in_build_mode

1
_log_not_in_build_mode() -> void

Flags: private

Logs that system is not in BUILD mode


_log_no_active_preview

1
_log_no_active_preview() -> void

Flags: private

Logs that there is no active preview


_increment_and_log_build_requests

1
_increment_and_log_build_requests() -> void

Flags: private

Increments build request count and logs it


_physics_process

1
_physics_process(delta: float) -> void

Flags: private

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


_start_drag

1
_start_drag() -> DragPathData

Flags: private

Internal: Start drag operation and return drag data. [return] DragPathData instance, or null if drag cannot start


_stop_drag

1
_stop_drag() -> void

Flags: private


_can_continue_dragging

1
_can_continue_dragging() -> bool

Flags: private