Table of Contents

Method GetPointsInRange

Namespace
Gamelogic.Grids2
Assembly
Gamelogic.Grids2.dll

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

grid IGrid<TPoint>

The grid to use for the calculations.

start TPoint

The starting point for the range calculation.

getConnectedPoints Func<TPoint, IEnumerable<TPoint>>

A function that returns a set of points connected to this point.

isAccessible Func<TPoint, bool>

Whether the cell at the given point can be reached.

getCellMoveCost Func<TPoint, TPoint, float>

A function that returns the move cost given a cell.

moveRange float

The range from which to return cells.

Returns

IEnumerable<TPoint>

IEnumerable<TPoint>.

Type Parameters

TPoint

The type of the grid point.

Remarks

note

Author: Justin Kivak.

See for detailed information on how to use this method.

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

grid IGrid<TPoint>

The grid to use for the calculations

start TPoint

The starting point for the range calculation

getConnectedPoints Func<TPoint, IEnumerable<TPoint>>

This function is used to get the connected Points to a point.

isAccessible Func<TPoint, bool>

Whether the given cell can be reached

getCellMoveCost Func<TPoint, TPoint, int>

A function that returns the move cost given a cell

moveRange int

The 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 for detailed information on how to use this method.