Debug system

This commit is contained in:
2025-05-05 22:50:35 -05:00
parent 631365aa38
commit 2b3cfc0eb7
13 changed files with 180 additions and 139 deletions

View File

@@ -1,52 +1,34 @@
extends Node
const MainMenu = preload("res://scenes/MainMenu.tscn");
const OverworldScene = preload("res://scenes/Meta/Overworld.tscn");
const OverworldScene = preload("res://scenes/Overworld.tscn");
enum DawnScene {
INITIAL,
MAIN_MENU,
OVERWORLD,
BATTLE,
COOKING
const SCENES:Dictionary[String, PackedScene] = {
"Initial": MainMenu,
"MainMenu": MainMenu,
"Overworld": OverworldScene
};
# static const SCENES:Dictionary[String, PackedScene] = {
# "MainMenu": MainMenu,
# "Overworld": OverworldScene
# };
var scene = "Initial";
var currentScene:Node = null;
var scene:DawnScene = DawnScene.INITIAL;
func _ready() -> void:
currentScene = get_tree().root.get_child(-1);
func getMainMenuScene():
return get_tree().current_scene.get_node("MainMenu");
func setScene(newScene:DawnScene) -> void:
func setScene(newScene:String) -> void:
print("Setting scene to " + str(newScene));
scene = newScene;
if not SCENES.has(newScene):
push_error("Scene not found: " + newScene);
return;
var root = get_tree().root;
print("Current scene: " + str(currentScene));
if currentScene:
currentScene.queue_free();
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));
var newSceneInstance = SCENES[newScene].instantiate();
if newSceneInstance:
root.add_child(newSceneInstance);
currentScene = newSceneInstance;