Files
Cozypaw-Hospital/scripts/autoload/InputManager.gd
Steven Wroblewski f7c8a7ec03 fix(poc): resolve evaluator and review findings
- Add RectangleShape2D to Character and InteractiveObject collision areas
- Fix HUD button signal connections in _ready()
- Fix character_placed signal emitting global_position
- Extract DEFAULT_DRAG_RADIUS constant in DragDropComponent
- Type Variant on JSON parsed variable in SaveManager
- Extract music symbol constants in HUD
- Refactor duplicated drag input code in InputManager

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 11:16:05 +02:00

41 lines
1.0 KiB
GDScript

## InputManager — abstracts touch and mouse input into unified drag signals.
extends Node
signal drag_started(position: Vector2)
signal drag_moved(position: Vector2)
signal drag_ended(position: Vector2)
var _is_dragging: bool = false
func _input(event: InputEvent) -> void:
if event is InputEventScreenTouch:
if event.pressed:
_emit_drag_started(event.position)
else:
_emit_drag_ended(event.position)
elif event is InputEventScreenDrag:
if _is_dragging:
_emit_drag_moved(event.position)
elif event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
if event.pressed:
_emit_drag_started(event.position)
else:
_emit_drag_ended(event.position)
elif event is InputEventMouseMotion and _is_dragging:
_emit_drag_moved(event.position)
func _emit_drag_started(pos: Vector2) -> void:
_is_dragging = true
drag_started.emit(pos)
func _emit_drag_moved(pos: Vector2) -> void:
drag_moved.emit(pos)
func _emit_drag_ended(pos: Vector2) -> void:
_is_dragging = false
drag_ended.emit(pos)