From cc39522279c235d52c66432b17e1ce10b402e368 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sat, 10 Jun 2023 18:15:09 +0800 Subject: [PATCH] refactoring --- src/Builtin/BaseProcesses.cs | 8 +++---- src/Debug/EcsDebug.cs | 42 ++++++------------------------------ src/EcsWorld.cs | 3 ++- 3 files changed, 12 insertions(+), 41 deletions(-) diff --git a/src/Builtin/BaseProcesses.cs b/src/Builtin/BaseProcesses.cs index a84d757..2d58b27 100644 --- a/src/Builtin/BaseProcesses.cs +++ b/src/Builtin/BaseProcesses.cs @@ -48,7 +48,7 @@ namespace DCFApixels.DragonECS _markers = new EcsProfilerMarker[targets.Length]; for (int i = 0; i < targets.Length; i++) { - _markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(PreInit)}")); + _markers[i] = new EcsProfilerMarker($"EcsRunner.{targets[i].GetType().Name}.{nameof(PreInit)}"); } } #endif @@ -77,7 +77,7 @@ namespace DCFApixels.DragonECS _markers = new EcsProfilerMarker[targets.Length]; for (int i = 0; i < targets.Length; i++) { - _markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Init)}")); + _markers[i] = new EcsProfilerMarker($"EcsRunner.{targets[i].GetType().Name}.{nameof(Init)}"); } } #endif @@ -107,7 +107,7 @@ namespace DCFApixels.DragonECS _markers = new EcsProfilerMarker[targets.Length]; for (int i = 0; i < targets.Length; i++) { - _markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Run)}")); + _markers[i] = new EcsProfilerMarker($"EcsRunner.{targets[i].GetType().Name}.{nameof(Run)}"); } } #endif @@ -136,7 +136,7 @@ namespace DCFApixels.DragonECS _markers = new EcsProfilerMarker[targets.Length]; for (int i = 0; i < targets.Length; i++) { - _markers[i] = new EcsProfilerMarker(EcsDebug.RegisterMark($"EcsRunner.{targets[i].GetType().Name}.{nameof(Destroy)}")); + _markers[i] = new EcsProfilerMarker($"EcsRunner.{targets[i].GetType().Name}.{nameof(Destroy)}"); } } #endif diff --git a/src/Debug/EcsDebug.cs b/src/Debug/EcsDebug.cs index 70bdf50..84cd9fc 100644 --- a/src/Debug/EcsDebug.cs +++ b/src/Debug/EcsDebug.cs @@ -9,12 +9,12 @@ namespace DCFApixels.DragonECS public readonly struct EcsProfilerMarker { public readonly int id; - public EcsProfilerMarker(int id) => this.id = id; - public EcsProfilerMarker(string name) => id = EcsDebug.RegisterMark(name); + internal EcsProfilerMarker(int id) => this.id = id; + public EcsProfilerMarker(string name) => id = DebugService.Instance.RegisterMark(name); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Begin() => EcsDebug.ProfileMarkBegin(id); + public void Begin() => DebugService.Instance.ProfileMarkBegin(id); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void End() => EcsDebug.ProfileMarkEnd(id); + public void End() => DebugService.Instance.ProfileMarkEnd(id); [MethodImpl(MethodImplOptions.AggressiveInlining)] public AutoScope Auto() => new AutoScope(id); public readonly ref struct AutoScope @@ -23,9 +23,9 @@ namespace DCFApixels.DragonECS public AutoScope(int id) { _id = id; - EcsDebug.ProfileMarkBegin(id); + DebugService.Instance.ProfileMarkBegin(id); } - public void Dispose() => EcsDebug.ProfileMarkEnd(_id); + public void Dispose() => DebugService.Instance.ProfileMarkEnd(_id); } } @@ -48,36 +48,6 @@ namespace DCFApixels.DragonECS { #if !DISABLE_DRAGONECS_DEBUGGER DebugService.Instance.Print(tag, v); -#endif - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int RegisterMark(string name) - { -#if !DISABLE_DRAGONECS_DEBUGGER - return DebugService.Instance.RegisterMark(name); -#else - return 0; -#endif - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void DeleteMark(string name) - { -#if !DISABLE_DRAGONECS_DEBUGGER - DebugService.Instance.DeleteMark(name); -#endif - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ProfileMarkBegin(int id) - { -#if !DISABLE_DRAGONECS_DEBUGGER - DebugService.Instance.ProfileMarkBegin(id); -#endif - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void ProfileMarkEnd(int id) - { -#if !DISABLE_DRAGONECS_DEBUGGER - DebugService.Instance.ProfileMarkEnd(id); #endif } } diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 0a41088..a07e2f7 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -12,8 +12,9 @@ namespace DCFApixels.DragonECS private const short DEATH_GEN_BIT = short.MinValue; private const int DEL_ENT_BUFFER_SIZE_OFFSET = 2; - public static EcsWorld[] Worlds = new EcsWorld[8]; + internal static EcsWorld[] Worlds = new EcsWorld[8]; private static IntDispenser _worldIdDispenser = new IntDispenser(0); + public static EcsWorld GetWorld(int index) => Worlds[index]; public readonly short uniqueID;