fix(items): safe cast in _try_return_to_chest, typed chest state param, object_states reset
- Replace unsafe direct cast in HoldableItem._try_return_to_chest() with guarded as-cast - Type set_chest_state() parameter as Array[String] to match RoomChest._get_spawned_ids() - Add else-branch in apply_save_data() to reset _object_states when key absent - Rename test_save_data_has_version_two to test_save_data_has_version_three
This commit is contained in:
@@ -63,7 +63,7 @@ func get_chest_state(chest_id: String) -> Array:
|
||||
return _chest_states.get(chest_id, [])
|
||||
|
||||
|
||||
func set_chest_state(chest_id: String, spawned_item_ids: Array) -> void:
|
||||
func set_chest_state(chest_id: String, spawned_item_ids: Array[String]) -> void:
|
||||
_chest_states[chest_id] = spawned_item_ids
|
||||
state_changed.emit()
|
||||
|
||||
@@ -108,6 +108,8 @@ func apply_save_data(data: Dictionary) -> void:
|
||||
_character_held_items = {}
|
||||
if data.has("object_states"):
|
||||
_object_states = data["object_states"]
|
||||
else:
|
||||
_object_states = {}
|
||||
if data.has("current_room"):
|
||||
current_room = data["current_room"]
|
||||
if data.has("music_volume"):
|
||||
|
||||
Reference in New Issue
Block a user