From 0367f67949ff5bc02b7bc217079fa82aab193c1f Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Sat, 15 Mar 2025 16:39:03 +0800 Subject: [PATCH] refinces refactoring --- src/Consts.cs | 6 +++--- src/DebugUtils/EcsDebug.cs | 34 +++++++++++++++++----------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Consts.cs b/src/Consts.cs index 7d3c657..4377352 100644 --- a/src/Consts.cs +++ b/src/Consts.cs @@ -47,8 +47,8 @@ namespace DCFApixels.DragonECS public static class EcsDefines { - public const bool DRAGONECS_ENABLE_DRAGONECS_DEBUGGER = -#if DRAGONECS_ENABLE_DRAGONECS_DEBUGGER + public const bool DRAGONECS_ENABLE_DEBUG_SERVICE = +#if DRAGONECS_ENABLE_DEBUG_SERVICE true; #else false; @@ -92,7 +92,7 @@ namespace DCFApixels.DragonECS - [Obsolete("DRAGONECS_ENABLE_DRAGONECS_DEBUGGER")] + [Obsolete("DRAGONECS_ENABLE_DEBUG_SERVICE")] public const bool ENABLE_DRAGONECS_DEBUGGER = #if ENABLE_DRAGONECS_DEBUGGER true; diff --git a/src/DebugUtils/EcsDebug.cs b/src/DebugUtils/EcsDebug.cs index 7b70d1e..3eac63d 100644 --- a/src/DebugUtils/EcsDebug.cs +++ b/src/DebugUtils/EcsDebug.cs @@ -13,39 +13,39 @@ namespace DCFApixels.DragonECS using static EcsConsts; public readonly struct EcsProfilerMarker { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE public readonly int id; #endif internal EcsProfilerMarker(int id) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE this.id = id; #endif } public EcsProfilerMarker(string name) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE id = DebugService.CurrentThreadInstance.RegisterMark(name); #endif } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Begin() { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE DebugService.CurrentThreadInstance.ProfilerMarkBegin(id); #endif } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void End() { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE DebugService.CurrentThreadInstance.ProfilerMarkEnd(id); #endif } [MethodImpl(MethodImplOptions.AggressiveInlining)] public AutoScope Auto() { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE return new AutoScope(id); #else return default; @@ -53,13 +53,13 @@ namespace DCFApixels.DragonECS } public readonly ref struct AutoScope { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE private readonly int _id; #endif [MethodImpl(MethodImplOptions.AggressiveInlining)] public AutoScope(int id) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE _id = id; DebugService.CurrentThreadInstance.ProfilerMarkBegin(id); #endif @@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Dispose() { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id); #endif } @@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void PrintWarning(object v) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE OnPrint(DEBUG_WARNING_TAG, v); DebugService.CurrentThreadInstance.PrintWarning(v); #endif @@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void PrintError(object v) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE OnPrint(DEBUG_ERROR_TAG, v); DebugService.CurrentThreadInstance.PrintError(v); #endif @@ -110,7 +110,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void PrintErrorAndBreak(object v) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE OnPrint(DEBUG_ERROR_TAG, v); DebugService.CurrentThreadInstance.PrintErrorAndBreak(v); #endif @@ -118,7 +118,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void PrintPass(object v) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE OnPrint(DEBUG_PASS_TAG, v); DebugService.CurrentThreadInstance.PrintPass(v); #endif @@ -126,7 +126,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Print() { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE OnPrint(string.Empty, null); DebugService.CurrentThreadInstance.Print(); #endif @@ -134,7 +134,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Print(object v) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE OnPrint(string.Empty, v); DebugService.CurrentThreadInstance.Print(v); #endif @@ -142,7 +142,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Print(string tag, object v) { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE OnPrint(tag, v); DebugService.CurrentThreadInstance.Print(tag, v); #endif @@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS [MethodImpl(MethodImplOptions.AggressiveInlining)] public static void Break() { -#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER +#if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE DebugService.CurrentThreadInstance.Break(); #endif }