Table of Contents

Class AbstractUniformGrid<TCell, TPoint>

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

This is the base class for grids that are not spliced; in other words, grids that have identical cells, with identical orientation, and in which grid points behave as (integer) vectors.

[Version(1, 0, 0)]
[Serializable]
public abstract class AbstractUniformGrid<TCell, TPoint> : IVectorGrid<TCell, TPoint, TPoint>, IGrid<TCell, TPoint>, IGrid<TPoint>, IGridSpace<TPoint>, IEnumerable<TPoint>, IEnumerable where TPoint : IGridPoint<TPoint>, IVectorPoint<TPoint>

Type Parameters

TCell
TPoint
Inheritance
AbstractUniformGrid<TCell, TPoint>
Implements
IVectorGrid<TCell, TPoint, TPoint>
IGrid<TCell, TPoint>
IGrid<TPoint>
IGridSpace<TPoint>
IEnumerable<TPoint>
Derived
Inherited Members
Extension Methods

Constructors

AbstractUniformGrid(int, int, Func<TPoint, bool>, Func<TPoint, TPoint>, Func<TPoint, TPoint>, IEnumerable<TPoint>)

Constructs a new hex grid with a shape determined by the IsInsider shape.

protected AbstractUniformGrid(int width, int height, Func<TPoint, bool> isInsideTest, Func<TPoint, TPoint> gridPointTransform, Func<TPoint, TPoint> inverseGridPointTransform, IEnumerable<TPoint> neighborDirections)

Parameters

width int

The with of the hex rectangle that will contain the grid.

height int

The height of the hex rectangle that will contain the grid.

isInsideTest Func<TPoint, bool>

A function that tests whether a given point is inside the grid.This function should not rely on the points given to it to be limited in any way by the specified with and height.

gridPointTransform Func<TPoint, TPoint>

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

inverseGridPointTransform Func<TPoint, TPoint>

This must be the inverse of the gridPointTransform function. Together, these functions make it possible to do things such as flip axes.

neighborDirections IEnumerable<TPoint>

Possible direction of the neighbor

Fields

contains

[NonSerialized]
protected Func<TPoint, bool> contains

Field Value

Func<TPoint, bool>

height

protected int height

Field Value

int

width

protected int width

Field Value

int

Properties

GridOrigin

Gives the Zero point as transform by this grids transforms.

protected abstract TPoint GridOrigin { get; }

Property Value

TPoint

InversePointTransform

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

Property Value

Func<TPoint, TPoint>

this[TPoint]

Gets the cell at the specified point.

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

Parameters

point TPoint

Property Value

TCell

NeighborDirections

public IEnumerable<TPoint> NeighborDirections { get; set; }

Property Value

IEnumerable<TPoint>

PointTransform

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

Property Value

Func<TPoint, TPoint>

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

ArrayPointFromPoint(int, int)

protected abstract ArrayPoint ArrayPointFromPoint(int hX, int hY)

Parameters

hX int
hY int

Returns

ArrayPoint

ArrayPointFromPoint(TPoint)

protected abstract ArrayPoint ArrayPointFromPoint(TPoint point)

Parameters

point TPoint

Returns

ArrayPoint

CloneStructure<TNewCell>()

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

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

Returns

IGrid<TNewCell, TPoint>

Type Parameters

TNewCell

Contains(TPoint)

Checks whether the given point is inside the grid, or not.

This function must be consistent with the enumerator that is returned with GetEnumerator(all points returned by the enumerator must be Inside, and all points that are inside must be returned by the enumerator).

public bool Contains(TPoint point)

Parameters

point TPoint

Returns

bool

GetAllNeighbors(TPoint)

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

public IEnumerable<TPoint> GetAllNeighbors(TPoint point)

Parameters

point TPoint

Returns

IEnumerable<TPoint>

GetEnumerator()

public IEnumerator<TPoint> GetEnumerator()

Returns

IEnumerator<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 becuase of an incorrect test function, or an incorrect storage rectangle.

Use for debugging.

[Version(1, 1, 0)]
public IEnumerable<TPoint> GetLargeSet(int n)

Parameters

n int

Returns

IEnumerable<TPoint>

GetNeighborDirections(int)

The only legal cellIndex to pass to this methid is 0

public IEnumerable<TPoint> GetNeighborDirections(int cellIndex)

Parameters

cellIndex int

Returns

IEnumerable<TPoint>

GetStoragePoints()

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

This is useful for debuggong shape functions.

[Version(1, 1, 0)]
public IEnumerable<TPoint> GetStoragePoints()

Returns

IEnumerable<TPoint>

PointFromArrayPoint(int, int)

protected abstract TPoint PointFromArrayPoint(int aX, int aY)

Parameters

aX int
aY int

Returns

TPoint

SetGridPointTransforms(Func<TPoint, TPoint>, Func<TPoint, TPoint>)

Set the GridPointTransform and InverseGridPointTransform.

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

Parameters

gridPointTransform Func<TPoint, TPoint>

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

inverseGridPointTransform Func<TPoint, TPoint>

This must be the inverse of the gridPointTransform function. Together, these functions make it possible to do things such as flip axes.