class_name SceneSystem extends Node const MainMenu = preload("res://scenes/MainMenu.tscn"); const OverworldScene = preload("res://scenes/Meta/Overworld.tscn"); enum DawnScene { INITIAL, MAIN_MENU, OVERWORLD, BATTLE, COOKING }; var scene:DawnScene = DawnScene.INITIAL; func getMainMenuScene(): return get_tree().current_scene.get_node("MainMenu"); func setScene(newScene:DawnScene) -> void: print("Setting scene to " + str(newScene)); scene = newScene; if newScene == DawnScene.MAIN_MENU: # Remove all non essential scenes # Add Main menu scene if not present var mainMenu = getMainMenuScene(); if mainMenu == null: var instance = MainMenu.instantiate(PackedScene.GEN_EDIT_STATE_DISABLED); get_tree().current_scene.add_child(instance); return if newScene == DawnScene.OVERWORLD: # Remove all non essential scenes var mainMenuScene = getMainMenuScene(); if mainMenuScene != null: mainMenuScene.queue_free(); # Add Overworld scene if not present var overworld = get_tree().current_scene.get_node("OverworldScene"); if overworld == null: var instance = OverworldScene.instantiate(PackedScene.GEN_EDIT_STATE_DISABLED); get_tree().current_scene.add_child(instance); return # error print("Scene not found: " + str(newScene));