diff --git a/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd b/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd index a825b1cf..e0b51503 100644 --- a/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd +++ b/addons/escoria-core/game/core-scripts/esc/commands/change_scene.gd @@ -83,6 +83,10 @@ func run(command_params: Array) -> int: ] ) + if escoria.main.current_scene \ + and escoria.game_scene.get_parent() == escoria.main.current_scene: + escoria.main.current_scene.remove_child(escoria.game_scene) + # Load room scene var room_scene = res_room.instance() if room_scene: diff --git a/addons/escoria-core/game/main.gd b/addons/escoria-core/game/main.gd index 26138bf6..9f1c6648 100644 --- a/addons/escoria-core/game/main.gd +++ b/addons/escoria-core/game/main.gd @@ -40,9 +40,9 @@ func set_scene(p_scene: Node) -> void: if current_scene != null: clear_scene() - add_child(p_scene) + if not p_scene in get_children(): + add_child(p_scene) move_child(p_scene, 0) - current_scene = p_scene check_game_scene_methods() @@ -59,7 +59,8 @@ func clear_scene() -> void: escoria.action_manager.clear_current_action() escoria.action_manager.clear_current_tool() - current_scene.remove_child(escoria.game_scene) + if escoria.game_scene.get_parent() == current_scene: + current_scene.remove_child(escoria.game_scene) remove_child(current_scene) current_scene.free() diff --git a/addons/escoria-ui-9verbs/game.gd b/addons/escoria-ui-9verbs/game.gd index 05cd7a3c..260c68ff 100644 --- a/addons/escoria-ui-9verbs/game.gd +++ b/addons/escoria-ui-9verbs/game.gd @@ -39,7 +39,7 @@ onready var pause_menu = $ui/pause_menu onready var inventory_ui = $ui/Control/panel_down/VBoxContainer/HBoxContainer\ /InventoryMargin/inventory_ui -func _ready(): +func _enter_tree(): ProjectSettings.set_setting("escoria/ui/tooltip_follows_mouse", false) escoria.action_manager.connect( "action_finished", @@ -47,6 +47,13 @@ func _ready(): "_on_action_finished" ) +func _exit_tree(): + escoria.action_manager.disconnect( + "action_finished", + self, + "_on_action_finished" + ) + ## BACKGROUND ## diff --git a/addons/escoria-ui-simplemouse/game.gd b/addons/escoria-ui-simplemouse/game.gd index 79aac69f..ba402f22 100644 --- a/addons/escoria-ui-simplemouse/game.gd +++ b/addons/escoria-ui-simplemouse/game.gd @@ -38,6 +38,12 @@ func _enter_tree(): "_on_action_finished" ) +func _exit_tree(): + escoria.action_manager.disconnect( + "action_finished", + self, + "_on_action_finished" + ) ## BACKGROUND ##