feat(items): add chest-return priority to HoldableItem and GameState v3 chest states
- HoldableItem._try_return_to_chest() snaps item back if within CHEST_RETURN_RADIUS (80px) - _on_drag_released checks chest return before hand-slot fallback - OutfitItem._on_drag_released checks chest return before outfit/hand-slot logic - GameState: _chest_states dict + get/set/clear_chest_state methods - GameState.get_save_data() bumped to version 3, includes chest_states - GameState.apply_save_data() restores chest_states from save data
This commit is contained in:
@@ -69,3 +69,33 @@ func test_holdable_item_detach_preserves_global_position() -> void:
|
||||
var hand_pos: Vector2 = character.get_node("HandLeft").global_position
|
||||
item._on_drag_picked_up(hand_pos)
|
||||
assert_eq(item.global_position, hand_pos)
|
||||
|
||||
|
||||
func test_try_return_to_chest_false_when_no_home_chest() -> void:
|
||||
var item: HoldableItem = HoldableItem.new()
|
||||
add_child_autofree(item)
|
||||
assert_false(item._try_return_to_chest())
|
||||
|
||||
|
||||
func test_try_return_to_chest_false_when_beyond_radius() -> void:
|
||||
var chest: RoomChest = RoomChest.new()
|
||||
chest.chest_id = "reception_desk"
|
||||
add_child_autofree(chest)
|
||||
chest.global_position = Vector2.ZERO
|
||||
var item: HoldableItem = HoldableItem.new()
|
||||
add_child_autofree(item)
|
||||
item.home_chest = chest
|
||||
item.global_position = Vector2(200.0, 0.0)
|
||||
assert_false(item._try_return_to_chest())
|
||||
|
||||
|
||||
func test_try_return_to_chest_true_when_within_radius() -> void:
|
||||
var chest: RoomChest = RoomChest.new()
|
||||
chest.chest_id = "reception_desk"
|
||||
add_child_autofree(chest)
|
||||
chest.global_position = Vector2.ZERO
|
||||
var item: HoldableItem = HoldableItem.new()
|
||||
add_child_autofree(item)
|
||||
item.home_chest = chest
|
||||
item.global_position = Vector2(40.0, 0.0)
|
||||
assert_true(item._try_return_to_chest())
|
||||
|
||||
Reference in New Issue
Block a user