using MoonTools.ECS.Collections; namespace MoonTools.ECS { public struct FilterBuilder { private TypeIndices ComponentTypeIndices; private FilterStorage FilterStorage; private IndexableSet Included; private IndexableSet Excluded; internal FilterBuilder(FilterStorage filterStorage, TypeIndices componentTypeIndices) { FilterStorage = filterStorage; ComponentTypeIndices = componentTypeIndices; Included = new IndexableSet(); Excluded = new IndexableSet(); } private FilterBuilder(FilterStorage filterStorage, TypeIndices componentTypeIndices, IndexableSet included, IndexableSet excluded) { FilterStorage = filterStorage; ComponentTypeIndices = componentTypeIndices; Included = included; Excluded = excluded; } public FilterBuilder Include() where TComponent : unmanaged { Included.Add(ComponentTypeIndices.GetIndex()); return new FilterBuilder(FilterStorage, ComponentTypeIndices, Included, Excluded); } public FilterBuilder Exclude() where TComponent : unmanaged { Excluded.Add(ComponentTypeIndices.GetIndex()); return new FilterBuilder(FilterStorage, ComponentTypeIndices, Included, Excluded); } public Filter Build() { return FilterStorage.CreateFilter(Included, Excluded); } } }