using Svelto.ECS; #if DEBUG using System; using System.Collections.Generic; using System.Reflection; public static class ExclusiveGroupDebugger { static ExclusiveGroupDebugger() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type[] types = assembly.GetTypes(); foreach (Type type in types) { if (type != null && type.IsClass && type.IsSealed && type.IsAbstract) //this means only static classes { var fields = type.GetFields(); foreach (var field in fields) { if (field.IsStatic && typeof(ExclusiveGroup).IsAssignableFrom(field.FieldType)) { var group = (ExclusiveGroup) field.GetValue(null); string name = $"{type.FullName}.{field.Name} ({(uint)group})"; GroupMap.idToName[(ExclusiveGroupStruct) group] = name; } if (field.IsStatic && typeof(ExclusiveGroupStruct).IsAssignableFrom(field.FieldType)) { var group = (ExclusiveGroupStruct) field.GetValue(null); string name = $"{type.FullName}.{field.Name} ({(uint)group})"; GroupMap.idToName[@group] = name; } } } } } } public static string ToName(this in ExclusiveGroupStruct group) { if (GroupMap.idToName.TryGetValue(group, out var name) == false) name = $""; return name; } } public static class GroupMap { static GroupMap() { GroupMap.idToName = new Dictionary(); } internal static readonly Dictionary idToName; } #else public static class ExclusiveGroupDebugger { public static string ToName(this in ExclusiveGroupStruct group) { return ((uint)group).ToString(); } } #endif