当前位置: 首页>>代码示例>>Java>>正文


Java PathPoint.isAssigned方法代码示例

本文整理汇总了Java中net.minecraft.pathfinding.PathPoint.isAssigned方法的典型用法代码示例。如果您正苦于以下问题:Java PathPoint.isAssigned方法的具体用法?Java PathPoint.isAssigned怎么用?Java PathPoint.isAssigned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.pathfinding.PathPoint的用法示例。


在下文中一共展示了PathPoint.isAssigned方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addToPath

import net.minecraft.pathfinding.PathPoint; //导入方法依赖的package包/类
private PathPoint[] addToPath(Entity entityIn, PathPoint pathpointStart, PathPoint pathpointEnd, float maxDistance) {
    // set start point values
    
//    pathpointStart.totalPathDistance = 0.0F;
//    pathpointStart.distanceToNext = pathpointStart.distanceToSquared(pathpointEnd);
//    pathpointStart.distanceToTarget = pathpointStart.distanceToNext;
//    pathpointStart.index = -1;        
    PPUtil.setTotalPathDistance(pathpointStart, 0f);
    float dist = pathpointStart.distanceToSquared(pathpointEnd);
    PPUtil.setDistanceToNext(pathpointStart, dist);
    PPUtil.setDistanceToTarget(pathpointStart, dist);
    PPUtil.setIndex(pathpointStart, -1);
    

    // clear and add out start point to the path
    path.clearPath();
    path.addPoint(pathpointStart);
    PathPoint curPoint = pathpointStart;

    // while still points in the path
    while (!path.isPathEmpty()) {

      PathPoint dequeued = path.dequeue();

      // we are at the end
      if (dequeued.equals(pathpointEnd)) {
        return createEntityPath(pathpointStart, pathpointEnd);
      }

      // if the dequed point is closer to the ned that our current one, make it
      // the current point
      if (dequeued.distanceToSquared(pathpointEnd) < curPoint.distanceToSquared(pathpointEnd)) {
        curPoint = dequeued;
      }
      dequeued.visited = true;

      // find options for the next point in the path
      
      int numPathOptions = nodeProcessor.findPathOptions(pathOptions, dequeued, pathpointEnd, maxDistance);
      //int numPathOptions = nodeProcessor.findPathOptions(pathOptions, entityIn, dequeued, pathpointEnd, maxDistance);

      for (int j = 0; j < numPathOptions; ++j) {
        PathPoint cadidatePoint = pathOptions[j];        
        float newTotalDistance = PPUtil.getTotalPathDistance(dequeued) + dequeued.distanceToSquared(cadidatePoint);
        if (newTotalDistance < maxDistance * 2.0F && (!cadidatePoint.isAssigned() || newTotalDistance < PPUtil.getTotalPathDistance(cadidatePoint))) {
          //cadidatePoint.previous = dequeued;
          PPUtil.setPrevious(cadidatePoint, dequeued);
          //cadidatePoint.totalPathDistance = newTotalDistance;
          PPUtil.setTotalPathDistance(cadidatePoint, newTotalDistance);        
          //cadidatePoint.distanceToNext = cadidatePoint.distanceToSquared(pathpointEnd);
          PPUtil.setDistanceToNext(cadidatePoint, cadidatePoint.distanceToSquared(pathpointEnd));
          if (cadidatePoint.isAssigned()) {
            //path.changeDistance(cadidatePoint, cadidatePoint.totalPathDistance + cadidatePoint.distanceToNext);
            path.changeDistance(cadidatePoint, PPUtil.getTotalPathDistance(cadidatePoint) + PPUtil.getDistanceToNext(cadidatePoint));
          } else {            
            PPUtil.setDistanceToTarget(cadidatePoint, PPUtil.getTotalPathDistance(cadidatePoint) + PPUtil.getDistanceToNext(cadidatePoint));
            path.addPoint(cadidatePoint);
          }
        }
      }
         
//      PathPoint cadidatePoint = new PathPoint(pathpointEnd.xCoord, pathpointEnd.yCoord, pathpointEnd.zCoord);
//      float newTotalDistance = dequeued.totalPathDistance + dequeued.distanceToSquared(cadidatePoint);
//      cadidatePoint.previous = dequeued;
//      cadidatePoint.totalPathDistance = newTotalDistance;
//      cadidatePoint.distanceToNext = cadidatePoint.distanceToSquared(pathpointEnd);
//      if (cadidatePoint.isAssigned()) {
//        path.changeDistance(cadidatePoint, cadidatePoint.totalPathDistance + cadidatePoint.distanceToNext);
//      } else {
//        cadidatePoint.distanceToTarget = cadidatePoint.totalPathDistance + cadidatePoint.distanceToNext;
//        path.addPoint(cadidatePoint);
//      }                 
    }

    if (curPoint == pathpointStart) {
      return null;
    } else {
      return createEntityPath(pathpointStart, curPoint);
    }
  }
 
开发者ID:SleepyTrousers,项目名称:EnderZoo,代码行数:81,代码来源:FlyingPathFinder.java


注:本文中的net.minecraft.pathfinding.PathPoint.isAssigned方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。