fix inject

This commit is contained in:
Mikhail 2024-03-14 00:24:23 +08:00
parent 5f009d4eb5
commit dcccd5afa6
3 changed files with 8 additions and 6 deletions

View File

@ -4,8 +4,8 @@ namespace DCFApixels.DragonECS
{
public class InjectionBranch
{
private Injector _source;
private Type _type;
private readonly Injector _source;
private readonly Type _type;
private InjectionNodeBase[] _nodes = new InjectionNodeBase[2];
private int _nodesCount = 0;
private bool _isDeclared = false;

View File

@ -24,11 +24,12 @@ namespace DCFApixels.DragonECS
{
_process = pipeline.GetProcess<IEcsInject<T>>();
}
public sealed override void Inject(object obj)
public sealed override void Inject(object raw)
{
T obj = (T)raw;
for (int i = 0; i < _process.Length; i++)
{
_process[i].Inject((T)obj);
_process[i].Inject(obj);
}
}
}

View File

@ -26,6 +26,7 @@ namespace DCFApixels.DragonECS
public void Inject<T>(T obj)
{
object raw = obj;
Type type = obj.GetType();
if (_branches.TryGetValue(type, out InjectionBranch branch) == false)
{
@ -41,7 +42,7 @@ namespace DCFApixels.DragonECS
InitBranch(branch);
}
}
branch.Inject(obj);
branch.Inject(raw);
}
#region Internal
@ -69,7 +70,7 @@ namespace DCFApixels.DragonECS
{
var type = item.Key;
var branch = item.Value;
if (type.IsAssignableFrom(branch.Type))
if (node.Type.IsAssignableFrom(branch.Type))
{
branch.AddNode(node);
}