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));
            }
        }