public Path FindPath(Point startPosition, Point endPosition, PathingPolygon pathingPolygon, FindPathData userData = null) { int depth; var pathPoints = FindPath(startPosition, endPosition, out depth, userData); if (pathPoints == null) { return(null); } var output = new Path(); output.Depth = depth; foreach (var point in pathPoints) { var node = pathingPolygon.GetNodeAtColumnRow(point.X, point.Y); output.AddWaypoint(node.Bounds.Center.ToVector2()); } return(output); }
/// <summary> /// Finds the path. /// </summary> /// <param name="startPosition">The start position.</param> /// <param name="endPosition">The end position.</param> /// <param name="pathingPolygon">The pathing polygon.</param> /// <param name="userData">The user data used when processing nodes.</param> /// <returns>A list of points defining the found path.</returns> public Path FindPath(Point startPosition, Point endPosition, PathingPolygon pathingPolygon, FindPathData userData) { var pathPoints = FindPath(startPosition, endPosition, out var depth, userData); if (!pathPoints.Any()) { return(new Path()); } var output = new Path { Depth = depth }; foreach (var(x, y) in pathPoints) { var node = pathingPolygon.GetNodeAtColumnRow(x, y); output.AddWaypoint(node.Bounds.Center.ToVector2(), 0f); } return(output); }
/// <summary> /// Finds the path. /// </summary> /// <param name="startColumn">The start column.</param> /// <param name="startRow">The start row.</param> /// <param name="endColumn">The end column.</param> /// <param name="endRow">The end row.</param> /// <param name="pathingPolygon">The pathing polygon to find the path inside of.</param> /// <param name="userData">The user data used when processing nodes.</param> /// <returns>A list of points defining the found path.</returns> public Path FindPath(int startColumn, int startRow, int endColumn, int endRow, PathingPolygon pathingPolygon, FindPathData userData) => FindPath(new Point(startColumn, startRow), new Point(endColumn, endRow), pathingPolygon, userData);