/// <summary> /// Returns the entity with the given entity name that appears after the target match. /// </summary> public LexiconEntityMatch GetEntityAfter(string entityName, LexiconEntityMatch targetMatch) { LexiconEntityMatch match = null; // TODO: I don't like this null check, or the return if (!string.IsNullOrEmpty(entityName)) { for (int i = EntityMatches.IndexOf(targetMatch) + 1; i < EntityMatches.Count; i++) { LexiconEntityMatch entityMatch = EntityMatches[i]; if (string.Equals(entityMatch.Entity.EntityName, targetMatch.Entity.EntityName, StringComparison.OrdinalIgnoreCase)) { // Break if we run into another entity of the same type. // E.g. for "Create a cube with a sphere on top" location should be null after cube. break; } if (string.Equals(entityMatch.Entity.EntityName, entityName, StringComparison.OrdinalIgnoreCase)) { match = entityMatch; break; } } } return(match); }
public List <LexiconEntityMatch> GetEntitiesAfter(string entityName, LexiconEntityMatch targetMatch) { List <LexiconEntityMatch> matches = new List <LexiconEntityMatch>(); if (!string.IsNullOrEmpty(entityName)) { for (int i = EntityMatches.IndexOf(targetMatch) + 1; i < EntityMatches.Count; i++) { LexiconEntityMatch entityMatch = EntityMatches[i]; if (string.Equals(entityMatch.Entity.EntityName, targetMatch.Entity.EntityName, StringComparison.OrdinalIgnoreCase)) { // Break if we run into another entity of the same type. // E.g. for "Create a cube with a sphere on top" location should be null after cube. break; } if (string.Equals(entityMatch.Entity.EntityName, entityName, StringComparison.OrdinalIgnoreCase)) { matches.Add(entityMatch); } } } return(matches); }
public static bool Matches(IEntity entity, int[] componentIndices, EntityMatches match = EntityMatches.All) { bool matches = false; switch (match) { case EntityMatches.All: matches = MatchesAll(entity, componentIndices); break; case EntityMatches.Any: matches = MatchesAny(entity, componentIndices); break; case EntityMatches.None: matches = !MatchesAny(entity, componentIndices); break; case EntityMatches.Exact: matches = MatchesExact(entity, componentIndices); break; } return(matches); }
public static bool Matches(EntityGroups groups1, EntityGroups groups2, EntityMatches match = EntityMatches.All) { bool matches = false; switch (match) { case EntityMatches.All: matches = groups1.HasAll(groups2); break; case EntityMatches.Any: matches = groups1.HasAny(groups2); break; case EntityMatches.None: matches = groups1.HasNone(groups2); break; case EntityMatches.Exact: matches = groups1 == groups2; break; } return(matches); }
EntityMatchGroup GetMatchGroup(EntityMatches match) { var matchGroup = subGroups[(int)match]; if (matchGroup == null) { matchGroup = new EntityMatchGroup(this, match); subGroups[(int)match] = matchGroup; } return(matchGroup); }
public static bool Matches(IEntity entity, int[] componentIndices, EntityMatches match = EntityMatches.All) { bool matches = false; switch (match) { case EntityMatches.All: matches = MatchesAll(entity, componentIndices); break; case EntityMatches.Any: matches = MatchesAny(entity, componentIndices); break; case EntityMatches.None: matches = !MatchesAny(entity, componentIndices); break; case EntityMatches.Exact: matches = MatchesExact(entity, componentIndices); break; } return matches; }
public static bool Matches(EntityGroups groups1, EntityGroups groups2, EntityMatches match = EntityMatches.All) { bool matches = false; switch (match) { case EntityMatches.All: matches = groups1.HasAll(groups2); break; case EntityMatches.Any: matches = groups1.HasAny(groups2); break; case EntityMatches.None: matches = groups1.HasNone(groups2); break; case EntityMatches.Exact: matches = groups1 == groups2; break; } return matches; }
public EntityMatch(EntityGroups groups, EntityMatches match = EntityMatches.All) { this.groups = groups; this.match = match; }
public EntityMatchGroup(IEntityGroup parent, EntityMatches match) { this.parent = parent; this.match = match; }
public IEntityGroup Filter(Type[] componentTypes, EntityMatches match = EntityMatches.All) { return(GetMatchGroup(match).GetGroupByComponentIndices(ComponentUtility.GetComponentIndices(componentTypes))); }
public IEntityGroup Filter(EntityGroups groups, EntityMatches match = EntityMatches.All) { return(GetMatchGroup(match).GetGroupByEntityGroup(groups)); }