/** * Returns an Enumeration of the active entities at the given coordinates. */ public Iterator<Entity> getEntities(Coords c) { return getEntities(c, false); }
retVal = this.getEntities(); private EntitySelector entitySelector = entry; private Entity current = null; private Iterator<Entity> iter = getEntities();
/** * Count all <code>Entity</code>s that pass the given selection criteria. * * @param selector the <code>EntitySelector</code> that implements test that an * entity must pass to be included. This value may be * <code>null</code> (in which case the count of all entities in * the game will be returned). * @return the <code>int</code> count of all entities that the selector * accepts. This value will not be <code>null</code> but it may be * empty. */ public int getSelectedEntityCount(EntitySelector selector) { int retVal = 0; // If no selector was supplied, return the count of all game entities. if (null == selector) { retVal = getNoOfEntities(); } // Otherwise, count the entities that meet the selection criteria. else { Iterator<Entity> iter = this.getEntities(); while (iter.hasNext()) { if (selector.accept(iter.next())) { retVal++; } } } // End use-selector // Return the number of selected entities. return retVal; }