Add Godot project shell
This commit is contained in:
59
godot/scripts/bootstrap/GameRoot.cs
Normal file
59
godot/scripts/bootstrap/GameRoot.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
#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}");
|
||||
|
||||
LoadBootScene(m_Settings.BootMode);
|
||||
}
|
||||
|
||||
public void LoadBootScene(DebugBootMode bootMode)
|
||||
{
|
||||
PackedScene? scene = bootMode switch
|
||||
{
|
||||
DebugBootMode.Smoke => SmokeScene,
|
||||
_ => 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>("DebugOverlay");
|
||||
if (overlay is not null && m_Settings is not null)
|
||||
{
|
||||
overlay.SetStatus(m_Settings, loadedSceneId);
|
||||
}
|
||||
}
|
||||
|
||||
[Export]
|
||||
public PackedScene? MenuScene { get; set; }
|
||||
|
||||
[Export]
|
||||
public PackedScene? SmokeScene { get; set; }
|
||||
|
||||
private Node? m_LoadedScene;
|
||||
private DebugSettings? m_Settings;
|
||||
}
|
||||
1
godot/scripts/bootstrap/GameRoot.cs.uid
Normal file
1
godot/scripts/bootstrap/GameRoot.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://b28od0hdkj1kx
|
||||
Reference in New Issue
Block a user