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)); }
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); }
public void RemoveQuery(IQuerySystem querySystem) { _poolQueryResults.Remove(querySystem); }