示例#1
0
        /// <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);
        }
示例#2
0
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
        EntityMatchGroup GetMatchGroup(EntityMatches match)
        {
            var matchGroup = subGroups[(int)match];

            if (matchGroup == null)
            {
                matchGroup            = new EntityMatchGroup(this, match);
                subGroups[(int)match] = matchGroup;
            }

            return(matchGroup);
        }
示例#6
0
        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;
        }
示例#7
0
        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;
        }
示例#8
0
 public EntityMatch(EntityGroups groups, EntityMatches match = EntityMatches.All)
 {
     this.groups = groups;
     this.match = match;
 }
示例#9
0
 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;
 }
示例#11
0
 public EntityMatchGroup(IEntityGroup parent, EntityMatches match)
 {
     this.parent = parent;
     this.match  = match;
 }
示例#12
0
 public IEntityGroup Filter(Type[] componentTypes, EntityMatches match = EntityMatches.All)
 {
     return(GetMatchGroup(match).GetGroupByComponentIndices(ComponentUtility.GetComponentIndices(componentTypes)));
 }
示例#13
0
 public IEntityGroup Filter(EntityGroups groups, EntityMatches match = EntityMatches.All)
 {
     return(GetMatchGroup(match).GetGroupByEntityGroup(groups));
 }