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
+14
View File
@@ -169,3 +169,17 @@ func test_detach_returns_item() -> void:
func test_detach_from_empty_hand_returns_null() -> void:
var returned: Node2D = _char.detach_item("left")
assert_null(returned)
func test_character_is_in_characters_group() -> void:
assert_true(_char.is_in_group("characters"))
func test_detach_item_preserves_global_position() -> void:
var item: Node2D = Node2D.new()
add_child_autofree(item)
_char.global_position = Vector2(200.0, 300.0)
_char.attach_item("left", item)
var expected_global: Vector2 = _char.get_node("HandLeft").global_position
_char.detach_item("left")
assert_eq(item.global_position, expected_global)