feat: working version with scopes.

This commit is contained in:
redglow
2026-07-18 12:09:43 +02:00
parent 23e160438f
commit 04f0b5ef16
15 changed files with 120 additions and 87 deletions
+30
View File
@@ -0,0 +1,30 @@
using System;
using System.Linq;
using Godot;
using Microsoft.Extensions.Logging;
using OwofGames.GodotLume;
namespace GodotHostTest.GodotDI;
internal class SceneInstantiator(IProvider provider) : ISceneInstantiator
{
/// <inheritdoc />
public Node Instantiate(PackedScene packedScene, Delegate? onScopeCreated = null)
{
var node = packedScene.Instantiate();
var scope = node.GetChildren().OfType<ServiceSource>().SingleOrDefault();
if (scope == null)
provider.Get<ILogger<SceneInstantiator>>().LogDebug(
"Instantiated the scene {PackedSceneName} through ISceneInstantiator.Instantiate, but no scope found.",
packedScene.GetName());
else
scope.ResolveInjectedNodes(provider, onScopeCreated);
return node;
}
public T Instantiate<T>(PackedScene packedScene, Delegate? onScopeCreated = null) where T : Node
{
throw new NotImplementedException();
}
}