示例#1
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (obj == null || getClass() != obj.getClass()) {
     return false;
   }
   VectorNode other = (VectorNode) obj;
   if (location == null) {
     if (other.location != null) {
       return false;
     }
   } else if (!location.equals(other.location)) {
     return false;
   }
   return true;
 }
  @Override
  public void onTick(float dt) {
    final Client client = (Client) Spout.getEngine();
    final Transform playerTransform = client.getPlayer().getPhysics().getTransform();
    final PlayerInputState state = client.getPlayer().input();
    final float speed = 50f;
    Vector3f motion = Vector3f.ZERO;
    if (state.getForward()) {
      motion = motion.add(playerTransform.forwardVector().mul(speed * -dt));
    }
    if (state.getBackward()) {
      motion = motion.add(playerTransform.forwardVector().mul(speed * dt));
    }
    if (state.getLeft()) {
      motion = motion.add(playerTransform.rightVector().mul(speed * -dt)); // TODO getLeftVector
    }
    if (state.getRight()) {
      motion = motion.add(playerTransform.rightVector().mul(speed * dt));
    }
    if (state.getJump()) {
      motion = motion.add(playerTransform.upVector().mul(speed * dt));
    }
    if (state.getCrouch()) {
      motion = motion.add(playerTransform.upVector().mul(speed * -dt));
    }

    client
        .getPlayer()
        .getPhysics()
        .setRotation(
            Quaternionf.fromAxesAnglesDeg(
                state.pitch(),
                state.yaw(),
                playerTransform.getRotation().getAxesAngleDeg().getZ()));

    if (!motion.equals(Vector3f.ZERO)) {
      client.getPlayer().getPhysics().translate(motion);
    }
  }
示例#3
0
 @Override
 public Iterable<AStarNode> getNeighbours() {
   List<AStarNode> nodes = Lists.newArrayList();
   for (int x = -1; x <= 1; x++) {
     for (int y = -1; y <= 1; y++) {
       for (int z = -1; z <= 1; z++) {
         if (x == 0 && y == 0 && z == 0) {
           continue;
         }
         Vector3f mod = location.add(x, y, z);
         if (mod.equals(location)) {
           continue;
         }
         VectorNode sub = getNewNode(mod);
         if (!isPassable(sub)) {
           continue;
         }
         nodes.add(sub);
       }
     }
   }
   return nodes;
 }