Click or drag to resize

AlgorithmsGetConnectedRaysTCell, TPoint Method

Returns a list containing lines connected to the given points. A line is a list of points. Only returns correct results for square or hex grids.

Namespace:  Gamelogic.Grids
Assembly:  Assembly-CSharp (in Assembly-CSharp.dll) Version: 0.0.0.0
Syntax
C#
public static IEnumerable<IEnumerable<TPoint>> GetConnectedRays<TCell, TPoint>(
	AbstractUniformGrid<TCell, TPoint> grid,
	TPoint point,
	Func<TPoint, TPoint, bool> isNeighborsConnected
)
where TPoint : Object, IVectorPoint<TPoint>, IGridPoint<TPoint>

Parameters

grid
Type: Gamelogic.GridsAbstractUniformGridTCell, TPoint
point
Type: TPoint
isNeighborsConnected
Type: SystemFuncTPoint, TPoint, Boolean
A functions that returns true or false, depending on whether two points can be considered connected when they are neighbors.For example, if you want rays of points that refer to cells of the same color, you can pass in a functions that compares the DefaultColors of cells.

Type Parameters

TCell
The type of cell of the grid that this algorithm takes.
TPoint
The type of point of the grid that this algorithm takes.

Return Value

Type: IEnumerableIEnumerableTPoint
Examples
private bool IsSameColour(point1, point2)
{
    return grid[point1].Color == grid[point2].Color;
}

private SomeMethod()
{
    ...
    var rays = GetConnectedRays<ColourCell, PointyHexPoint, PointyHexNeighborIndex>(
        grid, point, IsSameColour);
    ...
}
You can of course also use a lambda expression, like this:
//The following code returns all lines that radiate from the given point 
GetConnectedRays<ColourCell, PointyHexPoint, PointyHexNeighborIndex>(
    grid, point, (x, y) => grid[x].Color == grid[y].Color);
See Also