mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 18:14:37 +08:00
remove CustomInjectionNodes
This commit is contained in:
parent
f009ef9c1c
commit
e326ea4b9c
@ -141,6 +141,11 @@ namespace DCFApixels.DragonECS
|
|||||||
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
#if (DEBUG && !DISABLE_DEBUG) || ENABLE_DRAGONECS_ASSERT_CHEKS
|
||||||
_initMarker.Begin();
|
_initMarker.Begin();
|
||||||
#endif
|
#endif
|
||||||
|
var members = GetProcess<IEcsPipelineMember>();
|
||||||
|
for (int i = 0; i < members.Length; i++)
|
||||||
|
{
|
||||||
|
members[i].Pipeline = this;
|
||||||
|
}
|
||||||
_injector = _injectorBuilder.Build(this);
|
_injector = _injectorBuilder.Build(this);
|
||||||
_injectorBuilder = null;
|
_injectorBuilder = null;
|
||||||
|
|
||||||
@ -219,7 +224,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_injector.AddNode<object>();
|
_injector.AddNode<object>();
|
||||||
_injector.AddNode<EcsWorld>();
|
_injector.AddNode<EcsWorld>();
|
||||||
_injector.AddNode<EcsAspect>();
|
_injector.AddNode<EcsAspect>();
|
||||||
_injector.AddCustomNode(new PipelinePropertyInjectionNode());
|
_injector.AddNode<EcsPipeline>();
|
||||||
|
|
||||||
_basicLayer = EcsConsts.BASIC_LAYER;
|
_basicLayer = EcsConsts.BASIC_LAYER;
|
||||||
Layers = new LayerList(this, _basicLayer);
|
Layers = new LayerList(this, _basicLayer);
|
||||||
@ -560,13 +565,3 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
namespace DCFApixels.DragonECS.Internal
|
|
||||||
{
|
|
||||||
internal sealed class PipelinePropertyInjectionNode : CustomInjectionNode<IEcsPipelineMember, EcsPipeline>
|
|
||||||
{
|
|
||||||
public sealed override void InjectTo(IEcsPipelineMember system, EcsPipeline obj)
|
|
||||||
{
|
|
||||||
system.Pipeline = obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
|
||||||
public abstract class CustomInjectionNodeBase : InjectionNodeBase
|
|
||||||
{
|
|
||||||
protected CustomInjectionNodeBase(Type type) : base(type) { }
|
|
||||||
}
|
|
||||||
public abstract class CustomInjectionNode<TProcess, TType> : CustomInjectionNodeBase
|
|
||||||
where TProcess : IEcsProcess
|
|
||||||
{
|
|
||||||
private EcsProcess<TProcess> _processProperty;
|
|
||||||
private EcsProcess<IEcsInject<TType>> _process;
|
|
||||||
public CustomInjectionNode() : base(typeof(TType)) { }
|
|
||||||
public sealed override void Init(EcsPipeline pipeline)
|
|
||||||
{
|
|
||||||
_processProperty = pipeline.GetProcess<TProcess>();
|
|
||||||
_process = pipeline.GetProcess<IEcsInject<TType>>();
|
|
||||||
OnInitialized(pipeline);
|
|
||||||
}
|
|
||||||
public sealed override void Inject(object obj)
|
|
||||||
{
|
|
||||||
TType target = (TType)obj;
|
|
||||||
for (int i = 0; i < _process.Length; i++)
|
|
||||||
{
|
|
||||||
_process[i].Inject(target);
|
|
||||||
}
|
|
||||||
for (int i = 0; i < _processProperty.Length; i++)
|
|
||||||
{
|
|
||||||
InjectTo(_processProperty[i], target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public virtual void OnInitialized(EcsPipeline pipeline) { }
|
|
||||||
public abstract void InjectTo(TProcess system, TType obj);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 44ecc06211a7d12428151f2898e7d453
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -112,22 +112,6 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
private bool TryDeclareProperty(CustomInjectionNodeBase injectionProperty)
|
|
||||||
{
|
|
||||||
Type type = injectionProperty.Type;
|
|
||||||
if (_nodes.TryGetValue(type, out InjectionNodeBase oldNode))
|
|
||||||
{
|
|
||||||
Throw.Exception("Already declared");
|
|
||||||
}
|
|
||||||
InitNode(injectionProperty);
|
|
||||||
#if !REFLECTION_DISABLED
|
|
||||||
if (IsCanInstantiated(type))
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
InitBranch(new InjectionBranch(this, type, true));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Builder
|
public class Builder
|
||||||
{
|
{
|
||||||
@ -144,11 +128,6 @@ namespace DCFApixels.DragonECS
|
|||||||
_instance.TryDeclare<T>();
|
_instance.TryDeclare<T>();
|
||||||
return _source;
|
return _source;
|
||||||
}
|
}
|
||||||
public EcsPipeline.Builder AddCustomNode(CustomInjectionNodeBase injectionProperty)
|
|
||||||
{
|
|
||||||
_instance.TryDeclareProperty(injectionProperty);
|
|
||||||
return _source;
|
|
||||||
}
|
|
||||||
public EcsPipeline.Builder Inject<T>(T obj)
|
public EcsPipeline.Builder Inject<T>(T obj)
|
||||||
{
|
{
|
||||||
_initInjections.Add(new InitInject<T>(obj));
|
_initInjections.Add(new InitInject<T>(obj));
|
||||||
|
Loading…
Reference in New Issue
Block a user