This commit is contained in:
Mikhail 2024-10-31 14:54:16 +08:00
parent 28402472b0
commit b356257a54

View File

@ -56,52 +56,14 @@ namespace DCFApixels.DragonECS.Internal
[MetaID("3273527C9201285BAA0A463F700A50FB")] [MetaID("3273527C9201285BAA0A463F700A50FB")]
internal sealed class EcsPreInitRunner : EcsRunner<IEcsPreInit>, IEcsPreInit internal sealed class EcsPreInitRunner : EcsRunner<IEcsPreInit>, IEcsPreInit
{ {
#if DEBUG && !DISABLE_DEBUG private RunHelper _helper;
private EcsProfilerMarker[] _markers;
protected override void OnSetup() protected override void OnSetup()
{ {
_markers = new EcsProfilerMarker[Process.Length]; _helper = new RunHelper(this, nameof(IEcsPreInit.PreInit));
for (int i = 0; i < Process.Length; i++)
{
_markers[i] = new EcsProfilerMarker($"{Process[i].GetMeta().Name}.{nameof(PreInit)}");
} }
}
#endif
public void PreInit() public void PreInit()
{ {
#if DEBUG && !DISABLE_DEBUG _helper.Run(p => p.PreInit());
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)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
}
_markers[i].End();
}
#else
foreach (var item in Process)
{
try
{
item.PreInit();
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
}
}
#endif
} }
} }
#if ENABLE_IL2CPP #if ENABLE_IL2CPP
@ -115,49 +77,14 @@ namespace DCFApixels.DragonECS.Internal
[MetaID("ED85527C9201A391AB8EC0B734917859")] [MetaID("ED85527C9201A391AB8EC0B734917859")]
internal sealed class EcsInitRunner : EcsRunner<IEcsInit>, IEcsInit internal sealed class EcsInitRunner : EcsRunner<IEcsInit>, IEcsInit
{ {
#if DEBUG && !DISABLE_DEBUG private RunHelper _helper;
private EcsProfilerMarker[] _markers;
protected override void OnSetup() protected override void OnSetup()
{ {
_markers = new EcsProfilerMarker[Process.Length]; _helper = new RunHelper(this, nameof(IEcsInit.Init));
for (int i = 0; i < Process.Length; i++)
{
_markers[i] = new EcsProfilerMarker($"{Process[i].GetMeta().Name}.{nameof(Init)}");
} }
}
#endif
public void Init() public void Init()
{ {
#if DEBUG && !DISABLE_DEBUG _helper.Run(p => p.Init());
for (int i = 0, n = Process.Length < _markers.Length ? Process.Length : _markers.Length; i < n; i++)
{
_markers[i].Begin();
try
{
Process[i].Init();
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
}
_markers[i].End();
}
#else
foreach (var item in Process)
{
try { item.Init(); }
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
}
}
#endif
} }
} }
#if ENABLE_IL2CPP #if ENABLE_IL2CPP
@ -227,49 +154,14 @@ namespace DCFApixels.DragonECS.Internal
[MetaID("06A6527C92010430ACEB3DA520F272CC")] [MetaID("06A6527C92010430ACEB3DA520F272CC")]
internal sealed class EcsDestroyRunner : EcsRunner<IEcsDestroy>, IEcsDestroy internal sealed class EcsDestroyRunner : EcsRunner<IEcsDestroy>, IEcsDestroy
{ {
#if DEBUG && !DISABLE_DEBUG private RunHelper _helper;
private EcsProfilerMarker[] _markers;
protected override void OnSetup() protected override void OnSetup()
{ {
_markers = new EcsProfilerMarker[Process.Length]; _helper = new RunHelper(this, nameof(IEcsDestroy.Destroy));
for (int i = 0; i < Process.Length; i++)
{
_markers[i] = new EcsProfilerMarker($"{Process[i].GetMeta().Name}.{nameof(IEcsDestroy.Destroy)}");
} }
}
#endif
public void Destroy() public void Destroy()
{ {
#if DEBUG && !DISABLE_DEBUG _helper.Run(p => p.Destroy());
for (int i = 0, n = Process.Length < _markers.Length ? Process.Length : _markers.Length; i < n; i++)
{
_markers[i].Begin();
try
{
Process[i].Destroy();
}
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
}
_markers[i].End();
}
#else
foreach (var item in Process)
{
try { item.Destroy(); }
catch (Exception e)
{
#if DISABLE_CATH_EXCEPTIONS
throw;
#endif
EcsDebug.PrintError(e);
}
}
#endif
} }
} }
} }