#nullable enable using Godot; using SideScrollerGame.Debug; namespace SideScrollerGame.Bootstrap; public partial class GameRoot : Node { public override void _Ready() { m_Settings = DebugSettings.Load(); GD.Seed((ulong)m_Settings.Seed); GD.Print($"Debug boot: {m_Settings.BootMode}"); GD.Print($"Seed: {m_Settings.Seed}"); m_CommandNode = GetNodeOrNull("DebugCommandNode"); m_CommandNode?.Initialize(m_Settings); LoadBootScene(m_Settings.BootMode); } public void LoadBootScene(DebugBootMode bootMode) { PackedScene? scene = bootMode switch { DebugBootMode.Smoke => SmokeScene, DebugBootMode.ContentBrowser => ContentBrowserScene, DebugBootMode.DebugSandbox => DebugSandboxScene, _ => MenuScene }; string loadedSceneId = bootMode.ToString(); if (scene is null) { GD.PushError($"No scene configured for debug boot mode '{bootMode}'."); return; } if (m_LoadedScene is not null) { m_LoadedScene.QueueFree(); } m_LoadedScene = scene.Instantiate(); AddChild(m_LoadedScene); DebugOverlay? overlay = GetNodeOrNull("DebugOverlay"); if (overlay is not null && m_Settings is not null) { if (m_CommandNode is not null) { overlay.Bind(m_CommandNode.Service, m_Settings, loadedSceneId); } else { overlay.SetStatus(m_Settings, loadedSceneId); } } } [Export] public PackedScene? MenuScene { get; set; } [Export] public PackedScene? SmokeScene { get; set; } [Export] public PackedScene? ContentBrowserScene { get; set; } [Export] public PackedScene? DebugSandboxScene { get; set; } private Node? m_LoadedScene; private DebugSettings? m_Settings; private DebugCommandNode? m_CommandNode; }