refactoring

This commit is contained in:
Mikhail 2023-04-23 18:05:27 +08:00
parent ed30d58614
commit 79238733d7
3 changed files with 169 additions and 145 deletions

View File

@ -21,6 +21,9 @@ namespace DCFApixels.DragonECS
public interface IEcsBaseSystem : IEcsInitSystem, IEcsRunSystem, IEcsDestroySystem { }
namespace Internal
{
[DebugColor(DebugColor.Orange)]
public sealed class EcsPreInitRunner : EcsRunner<IEcsPreInitSystem>, IEcsPreInitSystem
{
#if DEBUG && !DISABLE_DEBUG
@ -50,6 +53,7 @@ namespace DCFApixels.DragonECS
}
#endif
}
[DebugColor(DebugColor.Orange)]
public sealed class EcsInitRunner : EcsRunner<IEcsInitSystem>, IEcsInitSystem
{
#if DEBUG && !DISABLE_DEBUG
@ -79,6 +83,7 @@ namespace DCFApixels.DragonECS
}
#endif
}
[DebugColor(DebugColor.Orange)]
public sealed class EcsRunRunner : EcsRunner<IEcsRunSystem>, IEcsRunSystem
{
#if DEBUG && !DISABLE_DEBUG
@ -109,6 +114,7 @@ namespace DCFApixels.DragonECS
}
#endif
}
[DebugColor(DebugColor.Orange)]
public sealed class EcsDestroyRunner : EcsRunner<IEcsDestroySystem>, IEcsDestroySystem
{
#if DEBUG && !DISABLE_DEBUG
@ -139,3 +145,4 @@ namespace DCFApixels.DragonECS
#endif
}
}
}

View File

@ -39,6 +39,18 @@ namespace DCFApixels.DragonECS
{
public void PreInject(object obj);
}
public interface IEcsInject<T> : IEcsSystem
{
public void Inject(T obj);
}
public interface IEcsPreInitInjectCallbacks : IEcsSystem
{
public void OnPreInitInjectionBefore();
public void OnPreInitInjectionAfter();
}
namespace Internal
{
[DebugHide, DebugColor(DebugColor.Gray)]
public sealed class PreInjectRunner : EcsRunner<IEcsPreInject>, IEcsPreInject
{
@ -47,12 +59,6 @@ namespace DCFApixels.DragonECS
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>
{
@ -68,13 +74,6 @@ namespace DCFApixels.DragonECS
_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
{
@ -87,6 +86,7 @@ namespace DCFApixels.DragonECS
foreach (var item in targets) item.OnPreInitInjectionBefore();
}
}
}
public class InjectSystemBase { }

View File

@ -15,6 +15,10 @@ namespace DCFApixels.DragonECS
public void OnComponentDel<T>(int entityID);
}
public interface IEcsComponentLifecycle : IEcsComponentAdd, IEcsComponentWrite, IEcsComponentDel { }
namespace Internal
{
[DebugColor(DebugColor.Orange)]
public sealed class EcsEntityAddComponentRunner : EcsRunner<IEcsComponentAdd>, IEcsComponentAdd
{
public void OnComponentAdd<T>(int entityID)
@ -22,6 +26,7 @@ namespace DCFApixels.DragonECS
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)
@ -29,6 +34,7 @@ namespace DCFApixels.DragonECS
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)
@ -36,7 +42,7 @@ namespace DCFApixels.DragonECS
foreach (var item in targets) item.OnComponentDel<T>(entityID);
}
}
}
public interface IEcsEntityCreate : IEcsSystem
{
@ -47,6 +53,10 @@ namespace DCFApixels.DragonECS
public void OnEntityDestroy(EcsEntity entity);
}
public interface IEcsEntityLifecycle : IEcsEntityCreate, IEcsEntityDestroy { }
namespace Internal
{
[DebugColor(DebugColor.Orange)]
public sealed class EcsEntityCreateRunner : EcsRunner<IEcsEntityCreate>, IEcsEntityCreate
{
public void OnEntityCreate(EcsEntity entity)
@ -54,6 +64,7 @@ namespace DCFApixels.DragonECS
foreach (var item in targets) item.OnEntityCreate(entity);
}
}
[DebugColor(DebugColor.Orange)]
public sealed class EcsEntityDestroyRunner : EcsRunner<IEcsEntityDestroy>, IEcsEntityDestroy
{
public void OnEntityDestroy(EcsEntity entity)
@ -61,7 +72,7 @@ namespace DCFApixels.DragonECS
foreach (var item in targets) item.OnEntityDestroy(entity);
}
}
}
public interface IEcsWorldCreate : IEcsSystem
{
@ -72,6 +83,10 @@ namespace DCFApixels.DragonECS
public void OnWorldDestroy(EcsWorld world);
}
public interface IEcsWorldLifecycle : IEcsWorldCreate, IEcsWorldDestroy { }
namespace Internal
{
[DebugColor(DebugColor.Orange)]
public sealed class EcsWorldCreateRunner : EcsRunner<IEcsWorldCreate>, IEcsWorldCreate
{
public void OnWorldCreate(EcsWorld world)
@ -79,6 +94,7 @@ namespace DCFApixels.DragonECS
foreach (var item in targets) item.OnWorldCreate(world);
}
}
[DebugColor(DebugColor.Orange)]
public sealed class EcsWorldDestryRunner : EcsRunner<IEcsWorldDestroy>, IEcsWorldDestroy
{
public void OnWorldDestroy(EcsWorld world)
@ -87,3 +103,4 @@ namespace DCFApixels.DragonECS
}
}
}
}