Esempio n. 1
0
        private PathEntity addToPath(Entity entity, PathPoint pathpoint, PathPoint pathpoint1, PathPoint pathpoint2,
                                     float f)
        {
            pathpoint.totalPathDistance = 0.0F;
            pathpoint.distanceToNext    = pathpoint.distanceTo(pathpoint1);
            pathpoint.distanceToTarget  = pathpoint.distanceToNext;
            path.clearPath();
            path.addPoint(pathpoint);
            PathPoint pathpoint3 = pathpoint;

            while (!path.isPathEmpty())
            {
                PathPoint pathpoint4 = path.dequeue();
                if (pathpoint4.Equals(pathpoint1))
                {
                    return(createEntityPath(pathpoint, pathpoint1));
                }
                if (pathpoint4.distanceTo(pathpoint1) < pathpoint3.distanceTo(pathpoint1))
                {
                    pathpoint3 = pathpoint4;
                }
                pathpoint4.isFirst = true;
                int i = findPathOptions(entity, pathpoint4, pathpoint2, pathpoint1, f);
                int j = 0;
                while (j < i)
                {
                    PathPoint pathpoint5 = pathOptions[j];
                    float     f1         = pathpoint4.totalPathDistance + pathpoint4.distanceTo(pathpoint5);
                    if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance)
                    {
                        pathpoint5.previous          = pathpoint4;
                        pathpoint5.totalPathDistance = f1;
                        pathpoint5.distanceToNext    = pathpoint5.distanceTo(pathpoint1);
                        if (pathpoint5.isAssigned())
                        {
                            path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext);
                        }
                        else
                        {
                            pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext;
                            path.addPoint(pathpoint5);
                        }
                    }
                    j++;
                }
            }
            if (pathpoint3 == pathpoint)
            {
                return(null);
            }
            else
            {
                return(createEntityPath(pathpoint, pathpoint3));
            }
        }
Esempio n. 2
0
 private PathEntity addToPath(Entity entity, PathPoint pathpoint, PathPoint pathpoint1, PathPoint pathpoint2,
     float f)
 {
     pathpoint.totalPathDistance = 0.0F;
     pathpoint.distanceToNext = pathpoint.distanceTo(pathpoint1);
     pathpoint.distanceToTarget = pathpoint.distanceToNext;
     path.clearPath();
     path.addPoint(pathpoint);
     PathPoint pathpoint3 = pathpoint;
     while (!path.isPathEmpty())
     {
         PathPoint pathpoint4 = path.dequeue();
         if (pathpoint4.Equals(pathpoint1))
         {
             return createEntityPath(pathpoint, pathpoint1);
         }
         if (pathpoint4.distanceTo(pathpoint1) < pathpoint3.distanceTo(pathpoint1))
         {
             pathpoint3 = pathpoint4;
         }
         pathpoint4.isFirst = true;
         int i = findPathOptions(entity, pathpoint4, pathpoint2, pathpoint1, f);
         int j = 0;
         while (j < i)
         {
             PathPoint pathpoint5 = pathOptions[j];
             float f1 = pathpoint4.totalPathDistance + pathpoint4.distanceTo(pathpoint5);
             if (!pathpoint5.isAssigned() || f1 < pathpoint5.totalPathDistance)
             {
                 pathpoint5.previous = pathpoint4;
                 pathpoint5.totalPathDistance = f1;
                 pathpoint5.distanceToNext = pathpoint5.distanceTo(pathpoint1);
                 if (pathpoint5.isAssigned())
                 {
                     path.changeDistance(pathpoint5, pathpoint5.totalPathDistance + pathpoint5.distanceToNext);
                 }
                 else
                 {
                     pathpoint5.distanceToTarget = pathpoint5.totalPathDistance + pathpoint5.distanceToNext;
                     path.addPoint(pathpoint5);
                 }
             }
             j++;
         }
     }
     if (pathpoint3 == pathpoint)
     {
         return null;
     }
     else
     {
         return createEntityPath(pathpoint, pathpoint3);
     }
 }
Esempio n. 3
0
        private int findPathOptions(Entity entity, PathPoint pathpoint, PathPoint pathpoint1, PathPoint pathpoint2,
                                    float f)
        {
            int i = 0;
            int j = 0;

            if (getVerticalOffset(entity, pathpoint.xCoord, pathpoint.yCoord + 1, pathpoint.zCoord, pathpoint1) > 0)
            {
                j = 1;
            }
            PathPoint pathpoint3 = getSafePoint(entity, pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord + 1,
                                                pathpoint1, j);
            PathPoint pathpoint4 = getSafePoint(entity, pathpoint.xCoord - 1, pathpoint.yCoord, pathpoint.zCoord,
                                                pathpoint1, j);
            PathPoint pathpoint5 = getSafePoint(entity, pathpoint.xCoord + 1, pathpoint.yCoord, pathpoint.zCoord,
                                                pathpoint1, j);
            PathPoint pathpoint6 = getSafePoint(entity, pathpoint.xCoord, pathpoint.yCoord, pathpoint.zCoord - 1,
                                                pathpoint1, j);

            if (pathpoint3 != null && !pathpoint3.isFirst && pathpoint3.distanceTo(pathpoint2) < f)
            {
                pathOptions[i++] = pathpoint3;
            }
            if (pathpoint4 != null && !pathpoint4.isFirst && pathpoint4.distanceTo(pathpoint2) < f)
            {
                pathOptions[i++] = pathpoint4;
            }
            if (pathpoint5 != null && !pathpoint5.isFirst && pathpoint5.distanceTo(pathpoint2) < f)
            {
                pathOptions[i++] = pathpoint5;
            }
            if (pathpoint6 != null && !pathpoint6.isFirst && pathpoint6.distanceTo(pathpoint2) < f)
            {
                pathOptions[i++] = pathpoint6;
            }
            return(i);
        }