mirror of
https://github.com/DCFApixels/DragonECS-AutoInjections.git
synced 2025-09-18 21:35:07 +08:00
update
This commit is contained in:
parent
92697989e1
commit
b801139e1c
@ -141,10 +141,10 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
private readonly struct InjectedPropertyRecord
|
private readonly struct InjectedPropertyRecord
|
||||||
{
|
{
|
||||||
public readonly IEcsSystem target;
|
public readonly IEcsProcess target;
|
||||||
public readonly IInjectedProperty property;
|
public readonly IInjectedProperty property;
|
||||||
public EcsInjectAttribute Attribute => property.GetAutoInjectAttribute();
|
public EcsInjectAttribute Attribute => property.GetAutoInjectAttribute();
|
||||||
public InjectedPropertyRecord(IEcsSystem target, IInjectedProperty property)
|
public InjectedPropertyRecord(IEcsProcess target, IInjectedProperty property)
|
||||||
{
|
{
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.property = property;
|
this.property = property;
|
||||||
@ -154,33 +154,30 @@ namespace DCFApixels.DragonECS
|
|||||||
|
|
||||||
[MetaTags(MetaTags.HIDDEN)]
|
[MetaTags(MetaTags.HIDDEN)]
|
||||||
[MetaColor(MetaColor.Gray)]
|
[MetaColor(MetaColor.Gray)]
|
||||||
public class AutoInjectSystem : IEcsInject<object>, IEcsPipelineMember, IEcsPreInitInjectProcess
|
public class AutoInjectSystem : IEcsInject<object>, IEcsPipelineMember, IOnInitInjectionComplete
|
||||||
{
|
{
|
||||||
private EcsPipeline _pipeline;
|
private EcsPipeline _pipeline;
|
||||||
EcsPipeline IEcsPipelineMember.Pipeline { get => _pipeline; set => _pipeline = value; }
|
EcsPipeline IEcsPipelineMember.Pipeline { get => _pipeline; set => _pipeline = value; }
|
||||||
|
|
||||||
private List<object> _delayedInjects = new List<object>();
|
private List<object> _delayedInjects = new List<object>();
|
||||||
private AutoInjectionMap _autoInjectionMap;
|
private AutoInjectionMap _autoInjectionMap;
|
||||||
private bool _preInitInjectCompleted = false;
|
private bool _isInitInjectionCompleted;
|
||||||
|
|
||||||
public void Inject(object obj)
|
public void Inject(object obj)
|
||||||
{
|
{
|
||||||
if (!_preInitInjectCompleted)
|
if (_isInitInjectionCompleted)
|
||||||
{
|
|
||||||
_delayedInjects.Add(obj);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
_autoInjectionMap.Inject(obj.GetType(), obj);
|
_autoInjectionMap.Inject(obj.GetType(), obj);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
public void OnPreInitInjectionBefore(EcsPipeline pipeline)
|
|
||||||
{
|
{
|
||||||
_pipeline = pipeline;
|
_delayedInjects.Add(obj);
|
||||||
}
|
}
|
||||||
public void OnPreInitInjectionAfter()
|
}
|
||||||
|
|
||||||
|
public void OnInitInjectionComplete()
|
||||||
{
|
{
|
||||||
_autoInjectionMap = new AutoInjectionMap(_pipeline);
|
_autoInjectionMap = new AutoInjectionMap(_pipeline);
|
||||||
_preInitInjectCompleted = true;
|
_isInitInjectionCompleted = true;
|
||||||
|
|
||||||
foreach (var obj in _delayedInjects)
|
foreach (var obj in _delayedInjects)
|
||||||
{
|
{
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
|
||||||
public interface IInjectRaw : IEcsSystem
|
|
||||||
{
|
|
||||||
void Inject(object obj);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user