/// <summary> /// Match /// /// Allows us to fetch entities with a defined SET of components /// </summary> /// <param name="query"></param> /// <returns></returns> public bool Match(IEntityQuery query) { // Empty queries always result in a match - equivalent to SELECT * FROM ENTITIES if (!(query.Exclusionset.Any() || query.OneSet.Any() || query.AllSet.Any())) { return(true); } //If there is an EXCLUDE set, and the entity contains any component types in that set, or subtypes of them, the entity is excluded. bool matched = !(query.Exclusionset.Any() && query.Exclusionset.Any(t => ComponentTypes.Any(t.IsAssignableFrom))); //If there are no matching exclusions, and the entity matches the ALL set, the entity is included if (matched && (query.AllSet.Any() && query.AllSet.Any(t => !ComponentTypes.Any(t.IsAssignableFrom)))) { matched = false; } //If the entity matches so far, and it matches the ONE set, it matches. if (matched && (query.OneSet.Any() && query.OneSet.Any(t => ComponentTypes.Any(t.IsAssignableFrom)))) { matched = false; } return(matched); }
internal bool IsAppliableComponent(BaseComponent component) { return(ComponentTypes.Any(e => e == component.GetType() || component.GetType().IsAssignableFrom(e))); }