mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
fix inject
This commit is contained in:
parent
5f009d4eb5
commit
dcccd5afa6
@ -4,8 +4,8 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
public class InjectionBranch
|
public class InjectionBranch
|
||||||
{
|
{
|
||||||
private Injector _source;
|
private readonly Injector _source;
|
||||||
private Type _type;
|
private readonly Type _type;
|
||||||
private InjectionNodeBase[] _nodes = new InjectionNodeBase[2];
|
private InjectionNodeBase[] _nodes = new InjectionNodeBase[2];
|
||||||
private int _nodesCount = 0;
|
private int _nodesCount = 0;
|
||||||
private bool _isDeclared = false;
|
private bool _isDeclared = false;
|
||||||
|
@ -24,11 +24,12 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
_process = pipeline.GetProcess<IEcsInject<T>>();
|
_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++)
|
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)
|
public void Inject<T>(T obj)
|
||||||
{
|
{
|
||||||
|
object raw = obj;
|
||||||
Type type = obj.GetType();
|
Type type = obj.GetType();
|
||||||
if (_branches.TryGetValue(type, out InjectionBranch branch) == false)
|
if (_branches.TryGetValue(type, out InjectionBranch branch) == false)
|
||||||
{
|
{
|
||||||
@ -41,7 +42,7 @@ namespace DCFApixels.DragonECS
|
|||||||
InitBranch(branch);
|
InitBranch(branch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
branch.Inject(obj);
|
branch.Inject(raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Internal
|
#region Internal
|
||||||
@ -69,7 +70,7 @@ namespace DCFApixels.DragonECS
|
|||||||
{
|
{
|
||||||
var type = item.Key;
|
var type = item.Key;
|
||||||
var branch = item.Value;
|
var branch = item.Value;
|
||||||
if (type.IsAssignableFrom(branch.Type))
|
if (node.Type.IsAssignableFrom(branch.Type))
|
||||||
{
|
{
|
||||||
branch.AddNode(node);
|
branch.AddNode(node);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user