update debug

This commit is contained in:
Mikhail 2023-12-31 21:03:00 +08:00
parent 0b6c1e8d26
commit 770c8c5522
3 changed files with 27 additions and 2 deletions

View File

@ -8,6 +8,7 @@
public const string DEBUG_PREFIX = "[DEBUG] ";
public const string DEBUG_WARNING_TAG = "WARNING";
public const string DEBUG_ERROR_TAG = "ERROR";
public const string DEBUG_PASS_TAG = "PASS";
public const string PRE_BEGIN_LAYER = nameof(PRE_BEGIN_LAYER);
public const string BEGIN_LAYER = nameof(BEGIN_LAYER);

View File

@ -33,6 +33,7 @@ namespace DCFApixels.DragonECS
{
public const string WARNING_TAG = EcsConsts.DEBUG_WARNING_TAG;
public const string ERROR_TAG = EcsConsts.DEBUG_ERROR_TAG;
public const string PASS_TAG = EcsConsts.DEBUG_PASS_TAG;
public static void Set<T>() where T : DebugService, new() => DebugService.Set<T>();
public static void Set(DebugService service) => DebugService.Set(service);
@ -40,6 +41,7 @@ namespace DCFApixels.DragonECS
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void PrintWarning(object v) => Print(EcsConsts.DEBUG_WARNING_TAG, v);
public static void PrintError(object v) => Print(EcsConsts.DEBUG_ERROR_TAG, v);
public static void PrintPass(object v) => Print(EcsConsts.DEBUG_PASS_TAG, v);
public static void Print()
{
#if !DISABLE_DRAGONECS_DEBUGGER
@ -156,6 +158,9 @@ namespace DCFApixels.DragonECS
case EcsDebug.WARNING_TAG:
Console.ForegroundColor = ConsoleColor.Yellow;
break;
case EcsDebug.PASS_TAG:
Console.ForegroundColor = ConsoleColor.Green;
break;
}
Console.WriteLine($"[{tag}] {v}");
Console.ForegroundColor = color;

View File

@ -469,11 +469,30 @@ namespace DCFApixels.DragonECS
{
list.Clear();
var itemsCount = GetComponentsCount(entityID);
for (var i = 0; i < _pools.Length; i++)
for (var i = 0; i < _poolsCount; i++)
{
if (_pools[i].Has(entityID))
{
itemsCount--;
list.Add(_pools[i].GetRaw(entityID));
if (itemsCount <= 0)
break;
}
}
}
public void GetComponentTypes(int entityID, HashSet<Type> typeSet)
{
typeSet.Clear();
var itemsCount = GetComponentsCount(entityID);
for (var i = 0; i < _poolsCount; i++)
{
if (_pools[i].Has(entityID))
{
itemsCount--;
typeSet.Add(_pools[i].ComponentType);
if (itemsCount <= 0)
break;
}
}
}
#endregion