mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-17 17:34:36 +08:00
fix inject
This commit is contained in:
parent
5f009d4eb5
commit
dcccd5afa6
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user