示例#1
0
        public List <Entity> Query(IQuerySystem querySystem)
        {
            // If query is already cached, just return it.
            if (_poolQueryResults.ContainsKey(querySystem))
            {
                return(_poolQueryResults[querySystem]);
            }

            // If query hasn't been cached, add it.
            return(AddQuery(querySystem));
        }
示例#2
0
        public List <Entity> AddQuery(IQuerySystem querySystem)
        {
            var queryResult = new List <Entity>();

            // Add all entities which meet the requirements of the query.
            foreach (Entity e in _pool)
            {
                if (querySystem.Query(e))
                {
                    queryResult.Add(e);
                }
            }

            // Store the query result for quick future access.
            _poolQueryResults[querySystem] = queryResult;
            return(queryResult);
        }
示例#3
0
 public void RemoveQuery(IQuerySystem querySystem)
 {
     _poolQueryResults.Remove(querySystem);
 }