Ejemplo n.º 1
0
  /** Removes all expired {@code Actor} from the {@code World}. */
  public void removeExpired() {
    Iterable<Actor> expired =
        Lambda.filter(
            register,
            new FilterFunc<Actor>() {
              @Override
              public boolean filter(Actor element) {
                return element.expired();
              }
            });

    for (Actor actor : expired) removeActor(actor);
  }
Ejemplo n.º 2
0
 /**
  * Returns a {@code Collection<T extends Actor>} of all {@code Actor} of the given class,
  * Regardless of their location on the {@code World}.
  *
  * @param <T> the generic type of the class to be returned
  * @param cls the {@code Class<T extends Actor>} of the {@code Actor} to be returned
  * @return a {@code Collection<T extends Actor>} of all {@code Actor} of the given class
  */
 public <T extends Actor> Collection<T> getActors(Class<T> cls) {
   return Lambda.toSet(Lambda.filterType(register, cls));
 }
Ejemplo n.º 3
0
 /**
  * Returns an {@code Actor} of the given class, regardless of the location on the {@code World} ,
  * or null if there is none. If there are multiple possible {@code Actor} that could be returned,
  * an arbitrary {@code Actor} is returned.
  *
  * @param <T> the generic type of the class to be returned
  * @param cls the {@code Class<T extends Actor>} of the {@code Actor} to be returned
  * @return an {@code Actor} of the given class
  */
 public <T extends Actor> T getActor(Class<T> cls) {
   return Lambda.first(Lambda.filterType(register, cls));
 }
Ejemplo n.º 4
0
 /**
  * Returns a {@code Collection<T extends Actor>} of all {@code Actor} of the given class located
  * at (x, y).
  *
  * @param <T> the generic type of the class to be returned
  * @param cls the {@code Class<T extends Actor>} of the {@code Actor} to be returned
  * @param x the x location being queried
  * @param y the y location being queried
  * @return a {@code Collection<T extends Actor>} of all {@code Actor} of the given class located
  *     at (x, y)
  */
 public <T extends Actor> Collection<T> getActorsAt(Class<T> cls, int x, int y) {
   return Lambda.toSet(Lambda.filterType(grid[x][y].actors, cls));
 }
Ejemplo n.º 5
0
 /**
  * Returns an {@code Actor} of the given class located at (x, y), or null if there is none. If
  * there are multiple possible {@code Actor} that could be returned, an arbitrary {@code Actor} is
  * returned.
  *
  * @param <T> the generic type of the class to be returned
  * @param cls the {@code Class<T extends Actor>} of the {@code Actor} to be returned
  * @param x the x location being queried
  * @param y the y location being queried
  * @return an {@code Actor} of the given class located at (x, y)
  */
 public <T extends Actor> T getActorAt(Class<T> cls, int x, int y) {
   return Lambda.first(Lambda.filterType(grid[x][y].actors, cls));
 }