using System;
using System.Linq;
using Godot;
using Microsoft.Extensions.Logging;
using OwofGames.GodotLume;
namespace GodotHostTest.AetherBind;
internal class SceneInstantiator(IProvider provider) : ISceneInstantiator
{
///
public Node Instantiate(PackedScene packedScene, Action? onScopeCreated = null)
{
var node = packedScene.Instantiate();
var scope = node.GetChildren().OfType().SingleOrDefault();
if (scope == null)
provider.Get>().LogDebug(
"Instantiated the scene {PackedSceneName} through ISceneInstantiator.Instantiate, but no scope found.",
packedScene.GetName());
else
scope.ResolveInjectedNodes(provider, onScopeCreated);
return node;
}
public T Instantiate(PackedScene packedScene, Delegate? onScopeCreated = null) where T : Node
{
throw new NotImplementedException();
}
}