using System; using System.Collections.Generic; namespace MoonTools.ECS { public class Filter { internal FilterSignature Signature; private ComponentDepot ComponentDepot; internal Filter(ComponentDepot componentDepot, HashSet included, HashSet excluded) { ComponentDepot = componentDepot; Signature = new FilterSignature(included, excluded); } public IEnumerable Entities => ComponentDepot.FilterEntities(this); public IEnumerable EntitiesInRandomOrder => ComponentDepot.FilterEntitiesRandom(this); public Entity RandomEntity => ComponentDepot.FilterRandomEntity(this); public int Count => ComponentDepot.FilterCount(this); public bool Empty => Count == 0; // WARNING: this WILL crash if the index is out of range! public Entity NthEntity(int index) => ComponentDepot.FilterNthEntity(this, index); } }