Method GetPointsInRange
GetPointsInRange<TPoint>(IGrid<TPoint>, TPoint, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, bool>, Func<TPoint, TPoint, float>, float)
A generic function that returns the points in range based on a given start point, moveRange, and a function that returns the cost of moving between neighboring cells.
public static IEnumerable<TPoint> GetPointsInRange<TPoint>(IGrid<TPoint> grid, TPoint start, Func<TPoint, IEnumerable<TPoint>> getConnectedPoints, Func<TPoint, bool> isAccessible, Func<TPoint, TPoint, float> getCellMoveCost, float moveRange)
Parameters
gridIGrid<TPoint>The grid to use for the calculations.
startTPointThe starting point for the range calculation.
getConnectedPointsFunc<TPoint, IEnumerable<TPoint>>A function that returns a set of points connected to this point.
isAccessibleFunc<TPoint, bool>Whether the cell at the given point can be reached.
getCellMoveCostFunc<TPoint, TPoint, float>A function that returns the move cost given a cell.
moveRangefloatThe range from which to return cells.
Returns
- IEnumerable<TPoint>
IEnumerable<TPoint>.
Type Parameters
TPointThe type of the grid point.
Remarks
note
Author: Justin Kivak.
See
GetPointsInRange<TPoint>(IGrid<TPoint>, TPoint, Func<TPoint, IEnumerable<TPoint>>, Func<TPoint, bool>, Func<TPoint, TPoint, int>, int)
A generic function that returns the points in range based on a given start point, moveRange, and a function that returns the cost of moving between neighboring cells.
public static IEnumerable<TPoint> GetPointsInRange<TPoint>(IGrid<TPoint> grid, TPoint start, Func<TPoint, IEnumerable<TPoint>> getConnectedPoints, Func<TPoint, bool> isAccessible, Func<TPoint, TPoint, int> getCellMoveCost, int moveRange)
Parameters
gridIGrid<TPoint>The grid to use for the calculations
startTPointThe starting point for the range calculation
getConnectedPointsFunc<TPoint, IEnumerable<TPoint>>This function is used to get the connected Points to a point.
isAccessibleFunc<TPoint, bool>Whether the given cell can be reached
getCellMoveCostFunc<TPoint, TPoint, int>A function that returns the move cost given a cell
moveRangeintThe range from which to return cells
Returns
- IEnumerable<TPoint>
Type Parameters
TPoint
Examples
Example usage:
var tilesInRange = Algorithms.GetPointsInRange(
grid,
start,
tile1, tile2 => DistanceBetween(tile1, tile2),
5f);
Remarks
note
Author: Justin Kivak
See