Manage save game in case of room loading failure (#441)
This commit is contained in:
@@ -70,7 +70,8 @@ func get_save_data() -> Dictionary:
|
||||
save_data["interactive"] = self.interactive
|
||||
save_data["state"] = self.state
|
||||
|
||||
if self.node.get("is_movable") and self.node.is_movable:
|
||||
if is_instance_valid(self.node) and \
|
||||
self.node.get("is_movable") and self.node.is_movable:
|
||||
save_data["global_transform"] = self.node.global_transform
|
||||
save_data["last_deg"] = wrapi(self.node._movable._get_angle() + 1, 0, 360)
|
||||
save_data["last_dir"] = self.node._movable.last_dir
|
||||
|
||||
@@ -180,7 +180,8 @@ func perform_script_events():
|
||||
)
|
||||
escoria.globals_manager.set_global(
|
||||
"ESC_LAST_SCENE",
|
||||
escoria.main.current_scene.global_id,
|
||||
escoria.main.current_scene.global_id \
|
||||
if escoria.main.current_scene != null else "",
|
||||
true
|
||||
)
|
||||
|
||||
|
||||
@@ -126,7 +126,9 @@ func set_camera_limits(camera_limit_id: int = 0) -> void:
|
||||
func save_game(p_savegame_res: Resource) -> void:
|
||||
p_savegame_res.main = {
|
||||
ESCSaveGame.MAIN_LAST_SCENE_GLOBAL_ID_KEY: last_scene_global_id,
|
||||
ESCSaveGame.MAIN_CURRENT_SCENE_FILENAME_KEY: current_scene.filename
|
||||
ESCSaveGame.MAIN_CURRENT_SCENE_FILENAME_KEY: current_scene.filename \
|
||||
if current_scene != null \
|
||||
else "No current scene (not loaded yet)"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user