using Godot; namespace GameJamDungeon { /// /// Utility class that loads and instantiates scenes. /// public interface IInstantiator { /// Scene tree. public SceneTree SceneTree { get; } /// /// Loads and instantiates the given scene. /// /// Path to the scene. /// Type of the scene's root. /// Instance of the scene. T LoadAndInstantiate(string path) where T : Node; } /// /// Utility class that loads and instantiates scenes. /// public class Instantiator : IInstantiator { public SceneTree SceneTree { get; } public Instantiator(SceneTree sceneTree) { SceneTree = sceneTree; } public T LoadAndInstantiate(string path) where T : Node { var scene = GD.Load(path); return scene.Instantiate(); } } }