/** * This method returns multiple entities from the internal list. * If only a single return value is expected, use getEntityBy() instead. * If nothing is found that matches the conditions, then an empty List will be returned. */ public List<Entity> GetEntitiesBy(EntityMatchDelegate match) { List<Entity> rtn = new List<Entity>(); foreach(Entity ent in this._entities) { if(match(ent)) { rtn.Add(ent); } } return rtn; }
/** * This method returns a single entity from the internal list. * The first entity that is matched by the passed delegate is chosen as the return. * If more return values are expected, use getEntitiesBy() instead. * If nothing is found that matches the conditions, then a null is returned instead. */ public Entity GetEntityBy(EntityMatchDelegate match) { Entity rtn = null; foreach(Entity ent in this._entities) { if(match(ent)) { rtn = ent; break; } } return rtn; }