Re-introduce prototype code
This commit is contained in:
9
src/utils/FpsCounter.cs
Normal file
9
src/utils/FpsCounter.cs
Normal 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
7
src/utils/GameInputs.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using Godot;
|
||||
|
||||
namespace GameJamDungeon
|
||||
{
|
||||
[InputMap]
|
||||
public partial class GameInputs;
|
||||
}
|
||||
40
src/utils/Instantiator.cs
Normal file
40
src/utils/Instantiator.cs
Normal 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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user