Table of Contents

Class LineGrid<TCell>

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

Represents a one dimensional grid; essentially an array that can work with maps.

LinePoints are automatically convertible to integers.

[Version(1, 8, 0)]
public class LineGrid<TCell> : IVectorGrid<TCell, LinePoint, LinePoint>, IGrid<TCell, LinePoint>, IGrid<LinePoint>, IGridSpace<LinePoint>, IEnumerable<LinePoint>, IEnumerable

Type Parameters

TCell
Inheritance
LineGrid<TCell>
Implements
Inherited Members
Extension Methods

Constructors

LineGrid(int)

public LineGrid(int size)

Parameters

size int

LineGrid(int, Func<LinePoint, bool>, Func<LinePoint, LinePoint>, Func<LinePoint, LinePoint>)

public LineGrid(int size, Func<LinePoint, bool> isInsideTest, Func<LinePoint, LinePoint> gridPointTransform, Func<LinePoint, LinePoint> inverseGridPointTransform)

Parameters

size int
isInsideTest Func<LinePoint, bool>
gridPointTransform Func<LinePoint, LinePoint>
inverseGridPointTransform Func<LinePoint, LinePoint>

LineGrid(int, int)

Used by auto code generators

public LineGrid(int size, int ignored)

Parameters

size int
ignored int

LineGrid(int, int, Func<LinePoint, bool>, Func<LinePoint, LinePoint>, Func<LinePoint, LinePoint>, IEnumerable<LinePoint>)

public LineGrid(int size, int dummy, Func<LinePoint, bool> isInsideTest, Func<LinePoint, LinePoint> gridPointTransform, Func<LinePoint, LinePoint> inverseGridPointTransform, IEnumerable<LinePoint> neighborDirections)

Parameters

size int
dummy int
isInsideTest Func<LinePoint, bool>
gridPointTransform Func<LinePoint, LinePoint>
inverseGridPointTransform Func<LinePoint, LinePoint>
neighborDirections IEnumerable<LinePoint>

Fields

DefaultNeighborDirections

protected static readonly LinePoint[] DefaultNeighborDirections

Field Value

LinePoint[]

contains

protected Func<LinePoint, bool> contains

Field Value

Func<LinePoint, bool>

Properties

InversePointTransform

protected Func<LinePoint, LinePoint> InversePointTransform { get; }

Property Value

Func<LinePoint, LinePoint>

this[LinePoint]

Accesses a cell in the given point.

public TCell this[LinePoint point] { get; set; }

Parameters

point LinePoint

Property Value

TCell

PointTransform

protected Func<LinePoint, LinePoint> PointTransform { get; }

Property Value

Func<LinePoint, LinePoint>

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

BeginShape()

public static LineOp<TCell> BeginShape()

Returns

LineOp<TCell>

CloneStructure<TNewCell>()

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

public IGrid<TNewCell, LinePoint> CloneStructure<TNewCell>()

Returns

IGrid<TNewCell, LinePoint>

Type Parameters

TNewCell

Contains(LinePoint)

Returns whether a point is inside the grid.

public bool Contains(LinePoint point)

Parameters

point LinePoint

Returns

bool

Remarks

Use this method to control the shape of the grid.

DefaultContains(LinePoint, int, int)

public static bool DefaultContains(LinePoint point, int width, int height)

Parameters

point LinePoint
width int
height int

Returns

bool

GetAllNeighbors(LinePoint)

Returns the neighbors of this point, regardless of whether they are in the grid or not.

public IEnumerable<LinePoint> GetAllNeighbors(LinePoint point)

Parameters

point LinePoint

Returns

IEnumerable<LinePoint>

GetEnumerator()

public IEnumerator<LinePoint> GetEnumerator()

Returns

IEnumerator<LinePoint>

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<LinePoint> GetLargeSet(int n)

Parameters

n int

Returns

IEnumerable<LinePoint>

GetNeighborDirections(int)

public IEnumerable<LinePoint> GetNeighborDirections(int cellIndex)

Parameters

cellIndex int

Returns

IEnumerable<LinePoint>

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<LinePoint> GetStoragePoints()

Returns

IEnumerable<LinePoint>

Segment(int)

public static LineGrid<TCell> Segment(int length)

Parameters

length int

Returns

LineGrid<TCell>

SetGridPointTransforms(Func<LinePoint, LinePoint>, Func<LinePoint, LinePoint>)

This functions make it possible to do things such as flip axes.

public void SetGridPointTransforms(Func<LinePoint, LinePoint> gridPointTransform, Func<LinePoint, LinePoint> inverseGridPointTransform)

Parameters

gridPointTransform Func<LinePoint, LinePoint>

Points returned by tis grid are transformed first with this delagate.

inverseGridPointTransform Func<LinePoint, LinePoint>

This must be the inverse of the gridPointTransform function.