Table of Contents

Class LayeredGrid<TCell, TPoint>

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

A layered grid is a 3D grid made out of layers of 2D grids with the same point type. Each layer can have a different shape.

Layered grids are accessed through LayeredPoints.

Note that neighbors are not implemented for this grid.If you need to use neighbor relationships, you need

to extend this class and configure neighbors. See also A new look at layered grids: setting up neighbors.

[Version(1, 8, 0)]
public class LayeredGrid<TCell, TPoint> : IGrid<TCell, LayeredPoint<TPoint>>, IGrid<LayeredPoint<TPoint>>, IGridSpace<LayeredPoint<TPoint>>, IEnumerable<LayeredPoint<TPoint>>, IEnumerable where TPoint : IGridPoint<TPoint>

Type Parameters

TCell
TPoint
Inheritance
LayeredGrid<TCell, TPoint>
Implements
IGrid<TCell, LayeredPoint<TPoint>>
Derived
Inherited Members
Extension Methods

Constructors

LayeredGrid(IGrid<TCell, TPoint>[])

protected LayeredGrid(IGrid<TCell, TPoint>[] layers)

Parameters

layers IGrid<TCell, TPoint>[]

LayeredGrid(int, int, int, Func<TPoint, bool>, Func<int, int, Func<TPoint, bool>, IGrid<TCell, TPoint>>)

public LayeredGrid(int width, int height, int layerCount, Func<TPoint, bool> contains, Func<int, int, Func<TPoint, bool>, IGrid<TCell, TPoint>> constructor)

Parameters

width int
height int
layerCount int
contains Func<TPoint, bool>
constructor Func<int, int, Func<TPoint, bool>, IGrid<TCell, TPoint>>

LayeredGrid(int, int, int, Func<TPoint, bool>, Func<int, int, int, Func<TPoint, bool>, IGrid<TCell, TPoint>>)

public LayeredGrid(int width, int height, int layerCount, Func<TPoint, bool> contains, Func<int, int, int, Func<TPoint, bool>, IGrid<TCell, TPoint>> constructor)

Parameters

width int
height int
layerCount int
contains Func<TPoint, bool>
constructor Func<int, int, int, Func<TPoint, bool>, IGrid<TCell, TPoint>>

Properties

this[LayeredPoint<TPoint>]

Accesses a cell in the given point.

public TCell this[LayeredPoint<TPoint> point] { get; set; }

Parameters

point LayeredPoint<TPoint>

Property Value

TCell

LayerCount

public int LayerCount { get; }

Property Value

int

Values

A enumerable containing all the values of this grid.

public IEnumerable<TCell> Values { get; }

Property Value

IEnumerable<TCell>

Examples

For example, the following two pieces of code do the same:

foreach(var point in grid)
{
	Debug.Log(grid[point]);
}

foreach(var value in grid.Values)
{
	Debug.Log(value);
}

Methods

CloneStructure<TNewCell>()

Returns a grid with exactly the same structure, but potentially holding elements of a different type.

public IGrid<TNewCell, LayeredPoint<TPoint>> CloneStructure<TNewCell>()

Returns

IGrid<TNewCell, LayeredPoint<TPoint>>

Type Parameters

TNewCell

Contains(LayeredPoint<TPoint>)

Returns whether a point is inside the grid.

public bool Contains(LayeredPoint<TPoint> point)

Parameters

point LayeredPoint<TPoint>

Returns

bool

Remarks

Use this method to control the shape of the grid.

GetAllNeighbors(LayeredPoint<TPoint>)

This method is not implemented. If you need a layered grid with neighbors configured (for example, if you want to use path finding or connected shapes), you need to make your own layered grid by extending from this one, and implement this method.

public virtual IEnumerable<LayeredPoint<TPoint>> GetAllNeighbors(LayeredPoint<TPoint> point)

Parameters

point LayeredPoint<TPoint>

Returns

IEnumerable<LayeredPoint<TPoint>>

GetEnumerator()

public IEnumerator<LayeredPoint<TPoint>> GetEnumerator()

Returns

IEnumerator<LayeredPoint<TPoint>>

GetLargeSet(int)

This functions returns a large number of points around the origin.

This is useful(when used with big enough n) to determine whether a grid that is missing points is doing so because of an incorrect test function, or an incorrect storage rectangle.

Use for debugging.

public IEnumerable<LayeredPoint<TPoint>> GetLargeSet(int n)

Parameters

n int

Returns

IEnumerable<LayeredPoint<TPoint>>

GetStoragePoints()

This method returns all points that can be contained by the storage rectangle for this grid.

This is useful for debugging shape functions.

public IEnumerable<LayeredPoint<TPoint>> GetStoragePoints()

Returns

IEnumerable<LayeredPoint<TPoint>>

Make<TShapeInfo, TGrid, TPoint2, TVectorPoint, TShapeOp>(int, TShapeInfo)

public static LayeredGrid<TCell, TPoint2> Make<TShapeInfo, TGrid, TPoint2, TVectorPoint, TShapeOp>(int layerCount, TShapeInfo shape) where TShapeInfo : AbstractShapeInfo<TShapeInfo, TGrid, TPoint2, TVectorPoint, TShapeOp> where TGrid : IGrid<TCell, TPoint2> where TPoint2 : IGridPoint<TPoint2>, ISplicedVectorPoint<TPoint2, TVectorPoint> where TVectorPoint : IVectorPoint<TVectorPoint>

Parameters

layerCount int
shape TShapeInfo

Returns

LayeredGrid<TCell, TPoint2>

Type Parameters

TShapeInfo
TGrid
TPoint2
TVectorPoint
TShapeOp

Make<TShapeInfo, TGrid, TPoint2, TVectorPoint, TShapeOp>(TShapeInfo[])

public static LayeredGrid<TCell, TPoint2> Make<TShapeInfo, TGrid, TPoint2, TVectorPoint, TShapeOp>(TShapeInfo[] shapes) where TShapeInfo : AbstractShapeInfo<TShapeInfo, TGrid, TPoint2, TVectorPoint, TShapeOp> where TGrid : IGrid<TCell, TPoint2> where TPoint2 : IGridPoint<TPoint2>, ISplicedVectorPoint<TPoint2, TVectorPoint> where TVectorPoint : IVectorPoint<TVectorPoint>

Parameters

shapes TShapeInfo[]

Returns

LayeredGrid<TCell, TPoint2>

Type Parameters

TShapeInfo
TGrid
TPoint2
TVectorPoint
TShapeOp