refinces refactoring

This commit is contained in:
DCFApixels 2025-03-15 16:39:03 +08:00
parent 4a7faa58b1
commit 0367f67949
2 changed files with 20 additions and 20 deletions

View File

@ -47,8 +47,8 @@ namespace DCFApixels.DragonECS
public static class EcsDefines public static class EcsDefines
{ {
public const bool DRAGONECS_ENABLE_DRAGONECS_DEBUGGER = public const bool DRAGONECS_ENABLE_DEBUG_SERVICE =
#if DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DRAGONECS_ENABLE_DEBUG_SERVICE
true; true;
#else #else
false; false;
@ -92,7 +92,7 @@ namespace DCFApixels.DragonECS
[Obsolete("DRAGONECS_ENABLE_DRAGONECS_DEBUGGER")] [Obsolete("DRAGONECS_ENABLE_DEBUG_SERVICE")]
public const bool ENABLE_DRAGONECS_DEBUGGER = public const bool ENABLE_DRAGONECS_DEBUGGER =
#if ENABLE_DRAGONECS_DEBUGGER #if ENABLE_DRAGONECS_DEBUGGER
true; true;

View File

@ -13,39 +13,39 @@ namespace DCFApixels.DragonECS
using static EcsConsts; using static EcsConsts;
public readonly struct EcsProfilerMarker public readonly struct EcsProfilerMarker
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
public readonly int id; public readonly int id;
#endif #endif
internal EcsProfilerMarker(int id) internal EcsProfilerMarker(int id)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
this.id = id; this.id = id;
#endif #endif
} }
public EcsProfilerMarker(string name) public EcsProfilerMarker(string name)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
id = DebugService.CurrentThreadInstance.RegisterMark(name); id = DebugService.CurrentThreadInstance.RegisterMark(name);
#endif #endif
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Begin() public void Begin()
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id); DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif #endif
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void End() public void End()
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkEnd(id); DebugService.CurrentThreadInstance.ProfilerMarkEnd(id);
#endif #endif
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope Auto() public AutoScope Auto()
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
return new AutoScope(id); return new AutoScope(id);
#else #else
return default; return default;
@ -53,13 +53,13 @@ namespace DCFApixels.DragonECS
} }
public readonly ref struct AutoScope public readonly ref struct AutoScope
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
private readonly int _id; private readonly int _id;
#endif #endif
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public AutoScope(int id) public AutoScope(int id)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
_id = id; _id = id;
DebugService.CurrentThreadInstance.ProfilerMarkBegin(id); DebugService.CurrentThreadInstance.ProfilerMarkBegin(id);
#endif #endif
@ -67,7 +67,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Dispose() public void Dispose()
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id); DebugService.CurrentThreadInstance.ProfilerMarkEnd(_id);
#endif #endif
} }
@ -94,7 +94,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintWarning(object v) public static void PrintWarning(object v)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_WARNING_TAG, v); OnPrint(DEBUG_WARNING_TAG, v);
DebugService.CurrentThreadInstance.PrintWarning(v); DebugService.CurrentThreadInstance.PrintWarning(v);
#endif #endif
@ -102,7 +102,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintError(object v) public static void PrintError(object v)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_ERROR_TAG, v); OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintError(v); DebugService.CurrentThreadInstance.PrintError(v);
#endif #endif
@ -110,7 +110,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintErrorAndBreak(object v) public static void PrintErrorAndBreak(object v)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_ERROR_TAG, v); OnPrint(DEBUG_ERROR_TAG, v);
DebugService.CurrentThreadInstance.PrintErrorAndBreak(v); DebugService.CurrentThreadInstance.PrintErrorAndBreak(v);
#endif #endif
@ -118,7 +118,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintPass(object v) public static void PrintPass(object v)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(DEBUG_PASS_TAG, v); OnPrint(DEBUG_PASS_TAG, v);
DebugService.CurrentThreadInstance.PrintPass(v); DebugService.CurrentThreadInstance.PrintPass(v);
#endif #endif
@ -126,7 +126,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print() public static void Print()
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(string.Empty, null); OnPrint(string.Empty, null);
DebugService.CurrentThreadInstance.Print(); DebugService.CurrentThreadInstance.Print();
#endif #endif
@ -134,7 +134,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print(object v) public static void Print(object v)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(string.Empty, v); OnPrint(string.Empty, v);
DebugService.CurrentThreadInstance.Print(v); DebugService.CurrentThreadInstance.Print(v);
#endif #endif
@ -142,7 +142,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Print(string tag, object v) public static void Print(string tag, object v)
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
OnPrint(tag, v); OnPrint(tag, v);
DebugService.CurrentThreadInstance.Print(tag, v); DebugService.CurrentThreadInstance.Print(tag, v);
#endif #endif
@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Break() public static void Break()
{ {
#if DEBUG || DRAGONECS_ENABLE_DRAGONECS_DEBUGGER #if DEBUG || DRAGONECS_ENABLE_DEBUG_SERVICE
DebugService.CurrentThreadInstance.Break(); DebugService.CurrentThreadInstance.Break();
#endif #endif
} }