// NOTE: these methods are very inefficient // this class should only be used in debugging contexts!! #if DEBUG using System; using System.Collections.Generic; namespace MoonTools.ECS { public abstract class DebugSystem : System { private Dictionary singleComponentFilters = new Dictionary(); protected DebugSystem(World world) : base(world) { } protected IEnumerable Debug_GetAllComponents(Entity entity) { foreach (var typeIndex in EntityStorage.ComponentTypeIndices(entity.ID)) { yield return ComponentDepot.UntypedGet(entity.ID, typeIndex); } } protected IEnumerable Debug_GetEntities(Type componentType) { if (!singleComponentFilters.ContainsKey(componentType)) { singleComponentFilters.Add(componentType, new Filter(FilterStorage, new HashSet(ComponentTypeIndices.GetIndex(componentType)), new HashSet())); } return singleComponentFilters[componentType].Entities; } protected IEnumerable Debug_SearchComponentType(string typeString) { foreach (var type in ComponentTypeIndices.Types) { if (type.ToString().ToLower().Contains(typeString.ToLower())) { yield return type; } } } } } #endif