/// <summary> /// Adds a path from start to end and returns the whole path (args: unused, start, end, unused, maxDistance) /// </summary> private PathEntity AddToPath(Entity par1Entity, PathPoint par2PathPoint, PathPoint par3PathPoint, PathPoint par4PathPoint, float par5) { par2PathPoint.TotalPathDistance = 0.0F; par2PathPoint.DistanceToNext = par2PathPoint.DistanceTo(par3PathPoint); par2PathPoint.DistanceToTarget = par2PathPoint.DistanceToNext; Path.ClearPath(); Path.AddPoint(par2PathPoint); PathPoint pathpoint = par2PathPoint; while (!Path.IsPathEmpty()) { PathPoint pathpoint1 = Path.Dequeue(); if (pathpoint1.Equals(par3PathPoint)) { return(CreateEntityPath(par2PathPoint, par3PathPoint)); } if (pathpoint1.DistanceTo(par3PathPoint) < pathpoint.DistanceTo(par3PathPoint)) { pathpoint = pathpoint1; } pathpoint1.IsFirst = true; int i = FindPathOptions(par1Entity, pathpoint1, par4PathPoint, par3PathPoint, par5); int j = 0; while (j < i) { PathPoint pathpoint2 = PathOptions[j]; float f = pathpoint1.TotalPathDistance + pathpoint1.DistanceTo(pathpoint2); if (!pathpoint2.IsAssigned() || f < pathpoint2.TotalPathDistance) { pathpoint2.Previous = pathpoint1; pathpoint2.TotalPathDistance = f; pathpoint2.DistanceToNext = pathpoint2.DistanceTo(par3PathPoint); if (pathpoint2.IsAssigned()) { Path.ChangeDistance(pathpoint2, pathpoint2.TotalPathDistance + pathpoint2.DistanceToNext); } else { pathpoint2.DistanceToTarget = pathpoint2.TotalPathDistance + pathpoint2.DistanceToNext; Path.AddPoint(pathpoint2); } } j++; } } if (pathpoint == par2PathPoint) { return(null); } else { return(CreateEntityPath(par2PathPoint, pathpoint)); } }