mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
refactoring
This commit is contained in:
parent
ed30d58614
commit
79238733d7
@ -21,121 +21,128 @@ namespace DCFApixels.DragonECS
|
||||
|
||||
public interface IEcsBaseSystem : IEcsInitSystem, IEcsRunSystem, IEcsDestroySystem { }
|
||||
|
||||
public sealed class EcsPreInitRunner : EcsRunner<IEcsPreInitSystem>, IEcsPreInitSystem
|
||||
namespace Internal
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void PreInit(EcsPipeline pipeline)
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsPreInitRunner : EcsRunner<IEcsPreInitSystem>, IEcsPreInitSystem
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void PreInit(EcsPipeline pipeline)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].PreInit(pipeline);
|
||||
}
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].PreInit(pipeline);
|
||||
}
|
||||
#else
|
||||
foreach (var item in targets) item.PreInit(pipeline);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(PreInit)}"));
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(PreInit)}"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
public sealed class EcsInitRunner : EcsRunner<IEcsInitSystem>, IEcsInitSystem
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void Init(EcsPipeline pipeline)
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsInitRunner : EcsRunner<IEcsInitSystem>, IEcsInitSystem
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void Init(EcsPipeline pipeline)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].Init(pipeline);
|
||||
}
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].Init(pipeline);
|
||||
}
|
||||
#else
|
||||
foreach (var item in targets) item.Init(pipeline);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Init)}"));
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Init)}"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
public sealed class EcsRunRunner : EcsRunner<IEcsRunSystem>, IEcsRunSystem
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void Run(EcsPipeline pipeline)
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsRunRunner : EcsRunner<IEcsRunSystem>, IEcsRunSystem
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void Run(EcsPipeline pipeline)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].Run(pipeline);
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].Run(pipeline);
|
||||
|
||||
}
|
||||
}
|
||||
#else
|
||||
foreach (var item in targets) item.Run(pipeline);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Run)}"));
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Run)}"));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
||||
public sealed class EcsDestroyRunner : EcsRunner<IEcsDestroySystem>, IEcsDestroySystem
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void Destroy(EcsPipeline pipeline)
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsDestroyRunner : EcsRunner<IEcsDestroySystem>, IEcsDestroySystem
|
||||
{
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
private EcsProfilerMarker[] _markers;
|
||||
#endif
|
||||
public void Destroy(EcsPipeline pipeline)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].Destroy(pipeline);
|
||||
}
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
for (int i = 0; i < targets.Length && targets.Length <= _markers.Length; i++)
|
||||
{
|
||||
using (_markers[i].Auto())
|
||||
targets[i].Destroy(pipeline);
|
||||
}
|
||||
#else
|
||||
foreach (var item in targets) item.Destroy(pipeline);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG && !DISABLE_DEBUG
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Destroy)}"));
|
||||
_markers = new EcsProfilerMarker[targets.Length];
|
||||
for (int i = 0; i < targets.Length; i++)
|
||||
{
|
||||
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Destroy)}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,52 +39,52 @@ namespace DCFApixels.DragonECS
|
||||
{
|
||||
public void PreInject(object obj);
|
||||
}
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public sealed class PreInjectRunner : EcsRunner<IEcsPreInject>, IEcsPreInject
|
||||
{
|
||||
void IEcsPreInject.PreInject(object obj)
|
||||
{
|
||||
foreach (var item in targets) item.PreInject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IEcsInject<T> : IEcsSystem
|
||||
{
|
||||
public void Inject(T obj);
|
||||
}
|
||||
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public sealed class InjectRunner<T> : EcsRunner<IEcsInject<T>>, IEcsInject<T>
|
||||
{
|
||||
private IEcsPreInject _preInjectchache;
|
||||
void IEcsInject<T>.Inject(T obj)
|
||||
{
|
||||
_preInjectchache.PreInject(obj);
|
||||
foreach (var item in targets) item.Inject(obj);
|
||||
}
|
||||
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_preInjectchache = Source.GetRunner<IEcsPreInject>();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IEcsPreInitInjectCallbacks : IEcsSystem
|
||||
{
|
||||
public void OnPreInitInjectionBefore();
|
||||
public void OnPreInitInjectionAfter();
|
||||
}
|
||||
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public sealed class InjectCallbacksRunner : EcsRunner<IEcsPreInitInjectCallbacks>, IEcsPreInitInjectCallbacks
|
||||
namespace Internal
|
||||
{
|
||||
public void OnPreInitInjectionAfter()
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public sealed class PreInjectRunner : EcsRunner<IEcsPreInject>, IEcsPreInject
|
||||
{
|
||||
foreach (var item in targets) item.OnPreInitInjectionAfter();
|
||||
void IEcsPreInject.PreInject(object obj)
|
||||
{
|
||||
foreach (var item in targets) item.PreInject(obj);
|
||||
}
|
||||
}
|
||||
public void OnPreInitInjectionBefore()
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public sealed class InjectRunner<T> : EcsRunner<IEcsInject<T>>, IEcsInject<T>
|
||||
{
|
||||
foreach (var item in targets) item.OnPreInitInjectionBefore();
|
||||
private IEcsPreInject _preInjectchache;
|
||||
void IEcsInject<T>.Inject(T obj)
|
||||
{
|
||||
_preInjectchache.PreInject(obj);
|
||||
foreach (var item in targets) item.Inject(obj);
|
||||
}
|
||||
|
||||
protected override void OnSetup()
|
||||
{
|
||||
_preInjectchache = Source.GetRunner<IEcsPreInject>();
|
||||
}
|
||||
}
|
||||
[DebugHide, DebugColor(DebugColor.Gray)]
|
||||
public sealed class InjectCallbacksRunner : EcsRunner<IEcsPreInitInjectCallbacks>, IEcsPreInitInjectCallbacks
|
||||
{
|
||||
public void OnPreInitInjectionAfter()
|
||||
{
|
||||
foreach (var item in targets) item.OnPreInitInjectionAfter();
|
||||
}
|
||||
public void OnPreInitInjectionBefore()
|
||||
{
|
||||
foreach (var item in targets) item.OnPreInitInjectionBefore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,28 +15,34 @@ namespace DCFApixels.DragonECS
|
||||
public void OnComponentDel<T>(int entityID);
|
||||
}
|
||||
public interface IEcsComponentLifecycle : IEcsComponentAdd, IEcsComponentWrite, IEcsComponentDel { }
|
||||
public sealed class EcsEntityAddComponentRunner : EcsRunner<IEcsComponentAdd>, IEcsComponentAdd
|
||||
{
|
||||
public void OnComponentAdd<T>(int entityID)
|
||||
{
|
||||
foreach (var item in targets) item.OnComponentAdd<T>(entityID);
|
||||
}
|
||||
}
|
||||
public sealed class EcsEntityChangeComponentRunner : EcsRunner<IEcsComponentWrite>, IEcsComponentWrite
|
||||
{
|
||||
public void OnComponentWrite<T>(int entityID)
|
||||
{
|
||||
foreach (var item in targets) item.OnComponentWrite<T>(entityID);
|
||||
}
|
||||
}
|
||||
public sealed class EcsEntityDelComponentRunner : EcsRunner<IEcsComponentDel>, IEcsComponentDel
|
||||
{
|
||||
public void OnComponentDel<T>(int entityID)
|
||||
{
|
||||
foreach (var item in targets) item.OnComponentDel<T>(entityID);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsEntityAddComponentRunner : EcsRunner<IEcsComponentAdd>, IEcsComponentAdd
|
||||
{
|
||||
public void OnComponentAdd<T>(int entityID)
|
||||
{
|
||||
foreach (var item in targets) item.OnComponentAdd<T>(entityID);
|
||||
}
|
||||
}
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsEntityChangeComponentRunner : EcsRunner<IEcsComponentWrite>, IEcsComponentWrite
|
||||
{
|
||||
public void OnComponentWrite<T>(int entityID)
|
||||
{
|
||||
foreach (var item in targets) item.OnComponentWrite<T>(entityID);
|
||||
}
|
||||
}
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsEntityDelComponentRunner : EcsRunner<IEcsComponentDel>, IEcsComponentDel
|
||||
{
|
||||
public void OnComponentDel<T>(int entityID)
|
||||
{
|
||||
foreach (var item in targets) item.OnComponentDel<T>(entityID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IEcsEntityCreate : IEcsSystem
|
||||
{
|
||||
@ -47,21 +53,26 @@ namespace DCFApixels.DragonECS
|
||||
public void OnEntityDestroy(EcsEntity entity);
|
||||
}
|
||||
public interface IEcsEntityLifecycle : IEcsEntityCreate, IEcsEntityDestroy { }
|
||||
public sealed class EcsEntityCreateRunner : EcsRunner<IEcsEntityCreate>, IEcsEntityCreate
|
||||
{
|
||||
public void OnEntityCreate(EcsEntity entity)
|
||||
{
|
||||
foreach (var item in targets) item.OnEntityCreate(entity);
|
||||
}
|
||||
}
|
||||
public sealed class EcsEntityDestroyRunner : EcsRunner<IEcsEntityDestroy>, IEcsEntityDestroy
|
||||
{
|
||||
public void OnEntityDestroy(EcsEntity entity)
|
||||
{
|
||||
foreach (var item in targets) item.OnEntityDestroy(entity);
|
||||
}
|
||||
}
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsEntityCreateRunner : EcsRunner<IEcsEntityCreate>, IEcsEntityCreate
|
||||
{
|
||||
public void OnEntityCreate(EcsEntity entity)
|
||||
{
|
||||
foreach (var item in targets) item.OnEntityCreate(entity);
|
||||
}
|
||||
}
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsEntityDestroyRunner : EcsRunner<IEcsEntityDestroy>, IEcsEntityDestroy
|
||||
{
|
||||
public void OnEntityDestroy(EcsEntity entity)
|
||||
{
|
||||
foreach (var item in targets) item.OnEntityDestroy(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface IEcsWorldCreate : IEcsSystem
|
||||
{
|
||||
@ -72,18 +83,24 @@ namespace DCFApixels.DragonECS
|
||||
public void OnWorldDestroy(EcsWorld world);
|
||||
}
|
||||
public interface IEcsWorldLifecycle : IEcsWorldCreate, IEcsWorldDestroy { }
|
||||
public sealed class EcsWorldCreateRunner : EcsRunner<IEcsWorldCreate>, IEcsWorldCreate
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
public void OnWorldCreate(EcsWorld world)
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsWorldCreateRunner : EcsRunner<IEcsWorldCreate>, IEcsWorldCreate
|
||||
{
|
||||
foreach (var item in targets) item.OnWorldCreate(world);
|
||||
public void OnWorldCreate(EcsWorld world)
|
||||
{
|
||||
foreach (var item in targets) item.OnWorldCreate(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
public sealed class EcsWorldDestryRunner : EcsRunner<IEcsWorldDestroy>, IEcsWorldDestroy
|
||||
{
|
||||
public void OnWorldDestroy(EcsWorld world)
|
||||
[DebugColor(DebugColor.Orange)]
|
||||
public sealed class EcsWorldDestryRunner : EcsRunner<IEcsWorldDestroy>, IEcsWorldDestroy
|
||||
{
|
||||
foreach (var item in targets) item.OnWorldDestroy(world);
|
||||
public void OnWorldDestroy(EcsWorld world)
|
||||
{
|
||||
foreach (var item in targets) item.OnWorldDestroy(world);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user