示例#1
0
  /**
   * Removes an {@code Actor} from the {@code World}. The {@code Actor} must be both bound to this
   * {@code World} and not held by another {@code Actor}. However, if the {@code Actor} is expired,
   * it may always be removed.
   *
   * @param actor the {@code Actor} to be removed
   */
  public void removeActor(Actor actor) {
    Guard.argumentIsNotNull(actor);
    Guard.verifyState(actor.bound(this));
    Guard.verifyState(!actor.held() || actor.expired());

    unregisterActor(actor);
    removeFromGrid(actor);
    actor.setWorld(null);
  }
示例#2
0
  public void tick() {
    for (Class<? extends Actor> cls : actOrder)
      for (Actor actor : getActors(cls)) {
        if (!actor.expired() && !actor.getClass().equals(Player.class)) {
          actor.act();
        }
      }

    removeExpired();
  }