feat(items): add HoldableItem with hand slot detection, fix detach_item position

- Character registers in "characters" group on _ready for group scanning
- detach_item saves/restores global_position after reparenting
- New HoldableItem base class: scans "characters" group on drag_released,
  attaches to nearest free hand within 60px radius, detaches on pickup

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Steven Wroblewski
2026-05-09 00:03:25 +02:00
parent 628f97fff5
commit ca1d20781e
4 changed files with 161 additions and 0 deletions
+3
View File
@@ -32,6 +32,7 @@ func _ready() -> void:
if data != null:
_update_visual_state()
_refresh_outfit_layers()
add_to_group("characters")
func set_state(new_state: CharacterData.State) -> void:
@@ -110,10 +111,12 @@ func detach_item(hand: String) -> Node2D:
if slot == null or slot.get_child_count() == 0:
return null
var item: Node2D = slot.get_child(0) as Node2D
var saved_pos: Vector2 = item.global_position
slot.remove_child(item)
var scene_parent: Node = get_parent()
if scene_parent != null:
scene_parent.add_child(item)
item.global_position = saved_pos
return item