2023-03-30 06:05:53 +08:00
|
|
|
|
namespace DCFApixels.DragonECS
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-03-30 06:03:05 +08:00
|
|
|
|
|
2023-03-12 20:45:18 +08:00
|
|
|
|
public interface IEcsPreInitSystem : IEcsSystem
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void PreInit(EcsPipeline pipeline);
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-03-12 20:45:18 +08:00
|
|
|
|
public interface IEcsInitSystem : IEcsSystem
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void Init(EcsPipeline pipeline);
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-03-12 20:45:18 +08:00
|
|
|
|
public interface IEcsRunSystem : IEcsSystem
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void Run(EcsPipeline pipeline);
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-03-12 20:45:18 +08:00
|
|
|
|
public interface IEcsDestroySystem : IEcsSystem
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void Destroy(EcsPipeline pipeline);
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-26 11:19:03 +08:00
|
|
|
|
public interface IEcsBaseSystem : IEcsInitSystem, IEcsRunSystem, IEcsDestroySystem { }
|
2023-03-12 02:02:39 +08:00
|
|
|
|
|
|
|
|
|
public sealed class EcsPreInitRunner : EcsRunner<IEcsPreInitSystem>, IEcsPreInitSystem
|
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-30 06:05:53 +08:00
|
|
|
|
private EcsProfilerMarker[] _markers;
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void PreInit(EcsPipeline pipeline)
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:03:05 +08:00
|
|
|
|
using (_markers[i].Auto())
|
|
|
|
|
targets[i].PreInit(pipeline);
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
#else
|
2023-03-30 05:32:43 +08:00
|
|
|
|
foreach (var item in targets) item.PreInit(pipeline);
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers = new EcsProfilerMarker[targets.Length];
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(PreInit)}"));
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
|
|
|
|
public sealed class EcsInitRunner : EcsRunner<IEcsInitSystem>, IEcsInitSystem
|
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-30 06:05:53 +08:00
|
|
|
|
private EcsProfilerMarker[] _markers;
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void Init(EcsPipeline pipeline)
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:03:05 +08:00
|
|
|
|
using (_markers[i].Auto())
|
|
|
|
|
targets[i].Init(pipeline);
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
#else
|
2023-03-30 05:32:43 +08:00
|
|
|
|
foreach (var item in targets) item.Init(pipeline);
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers = new EcsProfilerMarker[targets.Length];
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Init)}"));
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
|
|
|
|
public sealed class EcsRunRunner : EcsRunner<IEcsRunSystem>, IEcsRunSystem
|
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-30 06:05:53 +08:00
|
|
|
|
private EcsProfilerMarker[] _markers;
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void Run(EcsPipeline pipeline)
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:03:05 +08:00
|
|
|
|
using (_markers[i].Auto())
|
|
|
|
|
targets[i].Run(pipeline);
|
|
|
|
|
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
#else
|
2023-03-30 05:32:43 +08:00
|
|
|
|
foreach (var item in targets) item.Run(pipeline);
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers = new EcsProfilerMarker[targets.Length];
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Run)}"));
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
|
|
|
|
public sealed class EcsDestroyRunner : EcsRunner<IEcsDestroySystem>, IEcsDestroySystem
|
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-30 06:05:53 +08:00
|
|
|
|
private EcsProfilerMarker[] _markers;
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-30 05:32:43 +08:00
|
|
|
|
public void Destroy(EcsPipeline pipeline)
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:03:05 +08:00
|
|
|
|
using (_markers[i].Auto())
|
|
|
|
|
targets[i].Destroy(pipeline);
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
|
|
|
|
#else
|
2023-03-30 05:32:43 +08:00
|
|
|
|
foreach (var item in targets) item.Destroy(pipeline);
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2023-03-27 17:58:51 +08:00
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers = new EcsProfilerMarker[targets.Length];
|
2023-03-27 17:58:51 +08:00
|
|
|
|
for (int i = 0; i < targets.Length; i++)
|
|
|
|
|
{
|
2023-03-30 06:05:53 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Destroy)}"));
|
2023-03-27 17:58:51 +08:00
|
|
|
|
}
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|