2023-06-17 19:28:06 +08:00
|
|
|
|
#pragma warning disable CS0162 // Обнаружен недостижимый код
|
|
|
|
|
using DCFApixels.DragonECS.RunnersCore;
|
2023-06-18 00:41:44 +08:00
|
|
|
|
using System;
|
2023-03-30 06:03:05 +08:00
|
|
|
|
|
2023-04-23 17:55:01 +08:00
|
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
|
{
|
2023-12-20 23:16:57 +08:00
|
|
|
|
[MetaName(nameof(PreInit))]
|
2023-12-24 15:40:19 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-22 22:16:03 +08:00
|
|
|
|
public interface IEcsPreInit : IEcsProcess
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-12-06 18:58:06 +08:00
|
|
|
|
void PreInit();
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-12-20 23:16:57 +08:00
|
|
|
|
[MetaName(nameof(Init))]
|
2023-12-24 15:40:19 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-22 22:16:03 +08:00
|
|
|
|
public interface IEcsInit : IEcsProcess
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-12-06 18:58:06 +08:00
|
|
|
|
void Init();
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-12-20 23:16:57 +08:00
|
|
|
|
[MetaName(nameof(Run))]
|
2023-12-24 15:40:19 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-22 22:16:03 +08:00
|
|
|
|
public interface IEcsRun : IEcsProcess
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-12-06 18:58:06 +08:00
|
|
|
|
void Run();
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2023-12-20 23:16:57 +08:00
|
|
|
|
[MetaName(nameof(Destroy))]
|
2023-12-24 15:40:19 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-22 22:16:03 +08:00
|
|
|
|
public interface IEcsDestroy : IEcsProcess
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-12-06 18:58:06 +08:00
|
|
|
|
void Destroy();
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
2023-05-27 23:02:32 +08:00
|
|
|
|
|
2024-02-22 15:39:37 +08:00
|
|
|
|
namespace DCFApixels.DragonECS.Internal
|
|
|
|
|
{
|
2024-04-28 19:43:10 +08:00
|
|
|
|
#if ENABLE_IL2CPP
|
|
|
|
|
using Unity.IL2CPP.CompilerServices;
|
|
|
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
|
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-23 18:34:40 +08:00
|
|
|
|
internal sealed class EcsPreInitRunner : EcsRunner<IEcsPreInit>, IEcsPreInit
|
2023-03-12 02:02:39 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2024-02-22 15:39:37 +08:00
|
|
|
|
private EcsProfilerMarker[] _markers;
|
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
|
|
|
|
_markers = new EcsProfilerMarker[Process.Length];
|
|
|
|
|
for (int i = 0; i < Process.Length; i++)
|
2023-06-17 19:28:06 +08:00
|
|
|
|
{
|
2024-03-13 01:53:23 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker($"{Process[i].GetMeta().Name}.{nameof(PreInit)}");
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
2023-04-23 18:05:27 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
public void PreInit()
|
|
|
|
|
{
|
2023-04-23 18:05:27 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2024-02-22 15:39:37 +08:00
|
|
|
|
for (int i = 0, n = Process.Length < _markers.Length ? Process.Length : _markers.Length; i < n; i++)
|
|
|
|
|
{
|
|
|
|
|
_markers[i].Begin();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Process[i].PreInit();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
_markers[i].End();
|
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#else
|
2024-02-22 15:39:37 +08:00
|
|
|
|
foreach (var item in Process)
|
|
|
|
|
{
|
2024-02-23 18:34:40 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
item.PreInit();
|
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
catch (Exception e)
|
2023-06-17 19:28:06 +08:00
|
|
|
|
{
|
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-28 19:43:10 +08:00
|
|
|
|
#if ENABLE_IL2CPP
|
|
|
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
|
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-23 18:34:40 +08:00
|
|
|
|
internal sealed class EcsInitRunner : EcsRunner<IEcsInit>, IEcsInit
|
2024-02-22 15:39:37 +08:00
|
|
|
|
{
|
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
|
|
|
|
private EcsProfilerMarker[] _markers;
|
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
|
|
|
|
_markers = new EcsProfilerMarker[Process.Length];
|
|
|
|
|
for (int i = 0; i < Process.Length; i++)
|
|
|
|
|
{
|
2024-03-13 01:53:23 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker($"{Process[i].GetMeta().Name}.{nameof(Init)}");
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
#endif
|
|
|
|
|
public void Init()
|
2023-06-17 19:28:06 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2024-02-22 15:39:37 +08:00
|
|
|
|
for (int i = 0, n = Process.Length < _markers.Length ? Process.Length : _markers.Length; i < n; i++)
|
2023-03-27 17:58:51 +08:00
|
|
|
|
{
|
2024-02-22 15:39:37 +08:00
|
|
|
|
_markers[i].Begin();
|
|
|
|
|
try
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2024-02-22 15:39:37 +08:00
|
|
|
|
Process[i].Init();
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
catch (Exception e)
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
_markers[i].End();
|
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#else
|
2024-02-22 15:39:37 +08:00
|
|
|
|
foreach (var item in Process)
|
|
|
|
|
{
|
|
|
|
|
try { item.Init(); }
|
|
|
|
|
catch (Exception e)
|
2023-06-17 19:28:06 +08:00
|
|
|
|
{
|
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-28 19:43:10 +08:00
|
|
|
|
#if ENABLE_IL2CPP
|
|
|
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
|
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-23 18:34:40 +08:00
|
|
|
|
internal sealed class EcsRunRunner : EcsRunner<IEcsRun>, IEcsRun
|
2024-02-22 15:39:37 +08:00
|
|
|
|
{
|
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
|
|
|
|
private EcsProfilerMarker[] _markers;
|
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
|
|
|
|
_markers = new EcsProfilerMarker[Process.Length];
|
|
|
|
|
for (int i = 0; i < Process.Length; i++)
|
|
|
|
|
{
|
2024-03-13 01:53:23 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker($"{Process[i].GetMeta().Name}.{nameof(Run)}");
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
#endif
|
|
|
|
|
public void Run()
|
2023-06-17 19:28:06 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2024-02-22 15:39:37 +08:00
|
|
|
|
for (int i = 0, n = Process.Length < _markers.Length ? Process.Length : _markers.Length; i < n; i++)
|
2023-03-27 17:58:51 +08:00
|
|
|
|
{
|
2024-02-22 15:39:37 +08:00
|
|
|
|
_markers[i].Begin();
|
|
|
|
|
try
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2024-02-22 15:39:37 +08:00
|
|
|
|
Process[i].Run();
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
catch (Exception e)
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
_markers[i].End();
|
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#else
|
2024-02-22 15:39:37 +08:00
|
|
|
|
foreach (var item in Process)
|
|
|
|
|
{
|
|
|
|
|
try { item.Run(); }
|
|
|
|
|
catch (Exception e)
|
2023-06-17 19:28:06 +08:00
|
|
|
|
{
|
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-04-28 19:43:10 +08:00
|
|
|
|
#if ENABLE_IL2CPP
|
|
|
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
|
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
[MetaColor(MetaColor.Orange)]
|
2024-02-23 18:34:40 +08:00
|
|
|
|
internal sealed class EcsDestroyRunner : EcsRunner<IEcsDestroy>, IEcsDestroy
|
2024-02-22 15:39:37 +08:00
|
|
|
|
{
|
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
|
|
|
|
private EcsProfilerMarker[] _markers;
|
|
|
|
|
protected override void OnSetup()
|
|
|
|
|
{
|
|
|
|
|
_markers = new EcsProfilerMarker[Process.Length];
|
|
|
|
|
for (int i = 0; i < Process.Length; i++)
|
|
|
|
|
{
|
2024-03-13 01:53:23 +08:00
|
|
|
|
_markers[i] = new EcsProfilerMarker($"{Process[i].GetMeta().Name}.{nameof(IEcsDestroy.Destroy)}");
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
#endif
|
2024-02-23 18:34:40 +08:00
|
|
|
|
public void Destroy()
|
2023-06-17 19:28:06 +08:00
|
|
|
|
{
|
2023-04-07 03:12:56 +08:00
|
|
|
|
#if DEBUG && !DISABLE_DEBUG
|
2024-02-22 15:39:37 +08:00
|
|
|
|
for (int i = 0, n = Process.Length < _markers.Length ? Process.Length : _markers.Length; i < n; i++)
|
2023-03-27 17:58:51 +08:00
|
|
|
|
{
|
2024-02-22 15:39:37 +08:00
|
|
|
|
_markers[i].Begin();
|
|
|
|
|
try
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2024-02-22 15:39:37 +08:00
|
|
|
|
Process[i].Destroy();
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
catch (Exception e)
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
_markers[i].End();
|
|
|
|
|
}
|
2023-03-27 17:58:51 +08:00
|
|
|
|
#else
|
2024-02-22 15:39:37 +08:00
|
|
|
|
foreach (var item in Process)
|
|
|
|
|
{
|
|
|
|
|
try { item.Destroy(); }
|
|
|
|
|
catch (Exception e)
|
2023-04-23 18:05:27 +08:00
|
|
|
|
{
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#if DISABLE_CATH_EXCEPTIONS
|
2024-02-22 15:39:37 +08:00
|
|
|
|
throw;
|
2023-06-17 19:28:06 +08:00
|
|
|
|
#endif
|
2024-02-22 15:39:37 +08:00
|
|
|
|
EcsDebug.PrintError(e);
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2023-06-17 19:28:06 +08:00
|
|
|
|
}
|
2024-02-22 15:39:37 +08:00
|
|
|
|
#endif
|
2023-04-23 18:05:27 +08:00
|
|
|
|
}
|
2023-03-12 02:02:39 +08:00
|
|
|
|
}
|
|
|
|
|
}
|