Re-introduce prototype code

This commit is contained in:
2024-08-23 00:39:15 -07:00
parent 8b3d1bed8a
commit 2fb0c364ca
62 changed files with 1685 additions and 187 deletions

9
src/utils/FpsCounter.cs Normal file
View File

@@ -0,0 +1,9 @@
using Godot;
public partial class FpsCounter : Label
{
public override void _Process(double delta)
{
this.Text = Engine.GetFramesPerSecond().ToString();
}
}

7
src/utils/GameInputs.cs Normal file
View File

@@ -0,0 +1,7 @@
using Godot;
namespace GameJamDungeon
{
[InputMap]
public partial class GameInputs;
}

40
src/utils/Instantiator.cs Normal file
View File

@@ -0,0 +1,40 @@
using Godot;
namespace GameJamDungeon
{
/// <summary>
/// Utility class that loads and instantiates scenes.
/// </summary>
public interface IInstantiator
{
/// <summary>Scene tree.</summary>
public SceneTree SceneTree { get; }
/// <summary>
/// Loads and instantiates the given scene.
/// </summary>
/// <param name="path">Path to the scene.</param>
/// <typeparam name="T">Type of the scene's root.</typeparam>
/// <returns>Instance of the scene.</returns>
T LoadAndInstantiate<T>(string path) where T : Node;
}
/// <summary>
/// Utility class that loads and instantiates scenes.
/// </summary>
public class Instantiator : IInstantiator
{
public SceneTree SceneTree { get; }
public Instantiator(SceneTree sceneTree)
{
SceneTree = sceneTree;
}
public T LoadAndInstantiate<T>(string path) where T : Node
{
var scene = GD.Load<PackedScene>(path);
return scene.Instantiate<T>();
}
}
}