DragonECS-Unity/src/Buildin/UnityGameCyclieProcesses.cs

140 lines
4.2 KiB
C#
Raw Normal View History

2024-03-03 03:51:49 +08:00
using DCFApixels.DragonECS.Internal;
using DCFApixels.DragonECS.RunnersCore;
2023-04-24 16:48:26 +08:00
namespace DCFApixels.DragonECS
{
2023-06-16 11:54:41 +08:00
public interface IEcsGizmosProcess : IEcsProcess
{
public void DrawGizmos(EcsPipeline pipeline);
}
public static class IEcsGizmosProcessExtensions
{
public static void DrawGizmos(this EcsPipeline systems)
{
2024-03-03 03:51:49 +08:00
systems.GetRunnerInstance<EcsLateGizmosRunner>().DrawGizmos(systems);
2023-06-16 11:54:41 +08:00
}
}
2023-05-30 18:31:03 +08:00
public interface IEcsLateRunProcess : IEcsProcess
{
public void LateRun(EcsPipeline pipeline);
}
public static class IEcsLateRunSystemExtensions
{
2024-03-03 03:51:49 +08:00
public static void LateRun(this EcsPipeline pipeline)
{
2024-03-03 03:51:49 +08:00
pipeline.GetRunnerInstance<EcsLateRunRunner>().LateRun(pipeline);
}
}
2023-05-30 18:31:03 +08:00
public interface IEcsFixedRunProcess : IEcsProcess
{
public void FixedRun(EcsPipeline pipeline);
}
2023-04-24 16:48:26 +08:00
public static class IEcsFixedRunSystemExtensions
{
public static void FixedRun(this EcsPipeline pipeline)
{
2024-03-03 03:51:49 +08:00
pipeline.GetRunnerInstance<EcsFixedRunRunner>().FixedRun(pipeline);
2023-04-24 16:48:26 +08:00
}
}
namespace Internal
{
2024-03-03 03:51:49 +08:00
[MetaColor(MetaColor.Orange)]
public class EcsLateGizmosRunner : EcsRunner<IEcsGizmosProcess>, IEcsGizmosProcess
2023-06-16 11:54:41 +08:00
{
#if DEBUG && !DISABLE_DEBUG
private EcsProfilerMarker[] _markers;
#endif
public void DrawGizmos(EcsPipeline pipeline)
{
#if DEBUG && !DISABLE_DEBUG
2024-03-03 03:51:49 +08:00
for (int i = 0; i < Process.Length; i++)
2023-06-16 11:54:41 +08:00
{
using (_markers[i].Auto())
2024-03-03 03:51:49 +08:00
Process[i].DrawGizmos(pipeline);
2023-06-16 11:54:41 +08:00
}
#else
foreach (var item in targets) item.DrawGizmos(pipeline);
#endif
}
#if DEBUG && !DISABLE_DEBUG
protected override void OnSetup()
{
2024-03-03 03:51:49 +08:00
_markers = new EcsProfilerMarker[Process.Length];
for (int i = 0; i < Process.Length; i++)
2023-06-16 11:54:41 +08:00
{
2024-03-03 03:51:49 +08:00
_markers[i] = new EcsProfilerMarker($"{Process[i].GetType().Name}.{nameof(DrawGizmos)}");
2023-06-16 11:54:41 +08:00
}
}
#endif
}
2024-03-03 03:51:49 +08:00
[MetaColor(MetaColor.Orange)]
public class EcsLateRunRunner : EcsRunner<IEcsLateRunProcess>, IEcsLateRunProcess
2023-04-24 16:48:26 +08:00
{
2023-04-07 05:09:20 +08:00
#if DEBUG && !DISABLE_DEBUG
2023-04-24 16:48:26 +08:00
private EcsProfilerMarker[] _markers;
#endif
2023-04-24 16:48:26 +08:00
public void LateRun(EcsPipeline pipeline)
{
2023-04-07 05:09:20 +08:00
#if DEBUG && !DISABLE_DEBUG
2024-03-03 03:51:49 +08:00
for (int i = 0; i < Process.Length; i++)
2023-04-24 16:48:26 +08:00
{
using (_markers[i].Auto())
2024-03-03 03:51:49 +08:00
{
Process[i].LateRun(pipeline);
}
2023-04-24 16:48:26 +08:00
}
#else
foreach (var item in targets) item.LateRun(pipeline);
#endif
}
#if DEBUG && !DISABLE_DEBUG
protected override void OnSetup()
{
2024-03-03 03:51:49 +08:00
_markers = new EcsProfilerMarker[Process.Length];
for (int i = 0; i < Process.Length; i++)
2023-04-24 16:48:26 +08:00
{
2024-03-03 03:51:49 +08:00
_markers[i] = new EcsProfilerMarker($"EcsRunner.{Process[i].GetType().Name}.{nameof(LateRun)}");
2023-04-24 16:48:26 +08:00
}
}
2023-04-24 16:48:26 +08:00
#endif
}
2024-03-03 03:51:49 +08:00
[MetaColor(MetaColor.Orange)]
public class EcsFixedRunRunner : EcsRunner<IEcsFixedRunProcess>, IEcsFixedRunProcess
2023-04-24 16:48:26 +08:00
{
#if DEBUG && !DISABLE_DEBUG
private EcsProfilerMarker[] _markers;
#endif
public void FixedRun(EcsPipeline pipeline)
{
#if DEBUG && !DISABLE_DEBUG
2024-03-03 03:51:49 +08:00
for (int i = 0; i < Process.Length; i++)
2023-04-24 16:48:26 +08:00
{
using (_markers[i].Auto())
2024-03-03 03:51:49 +08:00
{
Process[i].FixedRun(pipeline);
}
2023-04-24 16:48:26 +08:00
}
#else
foreach (var item in targets) item.FixedRun(pipeline);
#endif
2023-04-24 16:48:26 +08:00
}
2023-04-07 05:09:20 +08:00
#if DEBUG && !DISABLE_DEBUG
2023-04-24 16:48:26 +08:00
protected override void OnSetup()
{
2024-03-03 03:51:49 +08:00
_markers = new EcsProfilerMarker[Process.Length];
for (int i = 0; i < Process.Length; i++)
2023-04-24 16:48:26 +08:00
{
2024-03-03 03:51:49 +08:00
_markers[i] = new EcsProfilerMarker($"EcsRunner.{Process[i].GetType().Name}.{nameof(FixedRun)}");
2023-04-24 16:48:26 +08:00
}
}
#endif
}
}
}