/**
   * Adds a path from start to end and returns the whole path (args: unused, start, end, unused,
   * maxDistance)
   */
  private PathEntity addToPath(
      Entity par1Entity,
      PathPoint par2PathPoint,
      PathPoint par3PathPoint,
      PathPoint par4PathPoint,
      float par5) {
    par2PathPoint.totalPathDistance = 0.0F;
    par2PathPoint.distanceToNext = par2PathPoint.func_75832_b(par3PathPoint);
    par2PathPoint.distanceToTarget = par2PathPoint.distanceToNext;
    this.path.clearPath();
    this.path.addPoint(par2PathPoint);
    PathPoint var6 = par2PathPoint;

    while (!this.path.isPathEmpty()) {
      PathPoint var7 = this.path.dequeue();

      if (var7.equals(par3PathPoint)) {
        return this.createEntityPath(par2PathPoint, par3PathPoint);
      }

      if (var7.func_75832_b(par3PathPoint) < var6.func_75832_b(par3PathPoint)) {
        var6 = var7;
      }

      var7.isFirst = true;
      int var8 = this.findPathOptions(par1Entity, var7, par4PathPoint, par3PathPoint, par5);

      for (int var9 = 0; var9 < var8; ++var9) {
        PathPoint var10 = this.pathOptions[var9];
        float var11 = var7.totalPathDistance + var7.func_75832_b(var10);

        if (!var10.isAssigned() || var11 < var10.totalPathDistance) {
          var10.previous = var7;
          var10.totalPathDistance = var11;
          var10.distanceToNext = var10.func_75832_b(par3PathPoint);

          if (var10.isAssigned()) {
            this.path.changeDistance(var10, var10.totalPathDistance + var10.distanceToNext);
          } else {
            var10.distanceToTarget = var10.totalPathDistance + var10.distanceToNext;
            this.path.addPoint(var10);
          }
        }
      }
    }

    if (var6 == par2PathPoint) {
      return null;
    } else {
      return this.createEntityPath(par2PathPoint, var6);
    }
  }
Beispiel #2
0
  /** Adds a path from start to end and returns the whole path */
  private PathEntity addToPath(
      Entity entityIn, PathPoint pathpointStart, PathPoint pathpointEnd, float maxDistance) {
    pathpointStart.totalPathDistance = 0.0F;
    pathpointStart.distanceToNext = pathpointStart.distanceToSquared(pathpointEnd);
    pathpointStart.distanceToTarget = pathpointStart.distanceToNext;
    this.path.clearPath();
    this.path.addPoint(pathpointStart);
    PathPoint pathpoint = pathpointStart;

    while (!this.path.isPathEmpty()) {
      PathPoint pathpoint1 = this.path.dequeue();

      if (pathpoint1.equals(pathpointEnd)) {
        return this.createEntityPath(pathpointStart, pathpointEnd);
      }

      if (pathpoint1.distanceToSquared(pathpointEnd) < pathpoint.distanceToSquared(pathpointEnd)) {
        pathpoint = pathpoint1;
      }

      pathpoint1.visited = true;
      int i =
          this.nodeProcessor.findPathOptions(
              this.pathOptions, entityIn, pathpoint1, pathpointEnd, maxDistance);

      for (int j = 0; j < i; ++j) {
        PathPoint pathpoint2 = this.pathOptions[j];
        float f = pathpoint1.totalPathDistance + pathpoint1.distanceToSquared(pathpoint2);

        if (f < maxDistance * 2.0F
            && (!pathpoint2.isAssigned() || f < pathpoint2.totalPathDistance)) {
          pathpoint2.previous = pathpoint1;
          pathpoint2.totalPathDistance = f;
          pathpoint2.distanceToNext = pathpoint2.distanceToSquared(pathpointEnd);

          if (pathpoint2.isAssigned()) {
            this.path.changeDistance(
                pathpoint2, pathpoint2.totalPathDistance + pathpoint2.distanceToNext);
          } else {
            pathpoint2.distanceToTarget = pathpoint2.totalPathDistance + pathpoint2.distanceToNext;
            this.path.addPoint(pathpoint2);
          }
        }
      }
    }

    if (pathpoint == pathpointStart) {
      return null;
    } else {
      return this.createEntityPath(pathpointStart, pathpoint);
    }
  }