예제 #1
0
  @Override
  public void onTick(float dt) {
    Controller cont = controllerLive.get();
    // Pulse all player messages here, so they can interact with the entities position safely
    if (cont instanceof PlayerController) {
      Player player = ((PlayerController) cont).getPlayer();
      if (player != null && player.getSession() != null) {
        ((SpoutSession) player.getSession()).pulse();
      }
    }

    // Tick the controller
    if (cont != null) {
      // Sanity check
      if (cont.getParent() != this) {
        if (Spout.debugMode()) {
          throw new IllegalStateException("Controller parent does not match entity");
        } else {
          cont.attachToEntity(this);
        }
      }
      // If this is the first tick, we need to attach the controller
      // Controller is attached here instead of inside of the constructor
      // because the constructor can not access getChunk if the entity is being deserialized
      if (!attached) {
        cont.onAttached();
        attached = true;
      }
      cont.onTick(dt);
    }

    // Copy values last (position may change during controller or session pulses)
    if (!isDead()
        && this.transform.getPosition() != null
        && this.transform.getPosition().getWorld() != null) {
      // Note: if the chunk is null, this effectively kills the entity (since dead: {chunkLive.get()
      // == null})
      chunkLive.set(
          transform.getPosition().getWorld().getChunkFromBlock(transform.getPosition(), false));

      entityManagerLive.set(((SpoutRegion) getRegion()).getEntityManager());
      lastTransform = transform.copy();
    }
  }
예제 #2
0
 @Override
 public Transform getSpawnPoint() {
   return spawnLocation.copy();
 }
예제 #3
0
 @Override
 public Transform getLastTransform() {
   return lastTransform.copy();
 }
예제 #4
0
 @Override
 public Transform getTransform() {
   return transform.copy();
 }