Table of Contents

Class RectGrid<TCell>

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

Represents a rectangular grid.

[Version(1, 0, 0)]
[Serializable]
public class RectGrid<TCell> : AbstractUniformGrid<TCell, RectPoint>, IEvenGrid<TCell, RectPoint, RectPoint>, IVectorGrid<TCell, RectPoint, RectPoint>, IGrid<TCell, RectPoint>, IGrid<RectPoint>, IGridSpace<RectPoint>, IEnumerable<RectPoint>, IEnumerable, ISupportsVertexGrid<RectPoint>, ISupportsEdgeGrid<DiamondPoint>

Type Parameters

TCell
Inheritance
RectGrid<TCell>
Implements
Inherited Members
Extension Methods

Constructors

RectGrid(int, int)

Construct a new grid in the default shape with the given width and height. No transformations are applied to the grid.

Normally, the static factory methods or shape building methods should be used to create grids. These constructors are provided for advanced usage.

public RectGrid(int width, int height)

Parameters

width int
height int

RectGrid(int, int, Func<RectPoint, bool>)

Construct a new grid whose cells are determined by the given test function.

The test function should only return true for points within the bounds of the default shape.

No transformations are applied to the grid.

Normally, the static factory methods or shape building methods should be used to create grids. These constructors are provided for advanced usage.

public RectGrid(int width, int height, Func<RectPoint, bool> isInside)

Parameters

width int
height int
isInside Func<RectPoint, bool>

RectGrid(int, int, Func<RectPoint, bool>, RectPoint)

Construct a new grid whose cells are determined by the given test function.

The function should only return true for points within the bounds of the rectangle when the given transforms are applied to them.

Normally, the static factory methods or shape building methods should be used to create grids. These constructors are provided for advanced usage.

public RectGrid(int width, int height, Func<RectPoint, bool> isInside, RectPoint offset)

Parameters

width int
height int
isInside Func<RectPoint, bool>
offset RectPoint

RectGrid(int, int, Func<RectPoint, bool>, Func<RectPoint, RectPoint>, Func<RectPoint, RectPoint>)

public RectGrid(int width, int height, Func<RectPoint, bool> isInside, Func<RectPoint, RectPoint> gridPointTransform, Func<RectPoint, RectPoint> inverseGridPointTransform)

Parameters

width int
height int
isInside Func<RectPoint, bool>
gridPointTransform Func<RectPoint, RectPoint>
inverseGridPointTransform Func<RectPoint, RectPoint>

RectGrid(int, int, Func<RectPoint, bool>, Func<RectPoint, RectPoint>, Func<RectPoint, RectPoint>, IEnumerable<RectPoint>)

public RectGrid(int width, int height, Func<RectPoint, bool> isInside, Func<RectPoint, RectPoint> gridPointTransform, Func<RectPoint, RectPoint> inverseGridPointTransform, IEnumerable<RectPoint> neighborDirections)

Parameters

width int
height int
isInside Func<RectPoint, bool>
gridPointTransform Func<RectPoint, RectPoint>
inverseGridPointTransform Func<RectPoint, RectPoint>
neighborDirections IEnumerable<RectPoint>

Properties

GridOrigin

Gives the Zero point as transform by this grids transforms.

protected override RectPoint GridOrigin { get; }

Property Value

RectPoint

Height

public int Height { get; }

Property Value

int

Width

public int Width { get; }

Property Value

int

Methods

ArrayPointFromGridPoint(RectPoint)

public static ArrayPoint ArrayPointFromGridPoint(RectPoint point)

Parameters

point RectPoint

Returns

ArrayPoint

ArrayPointFromPoint(RectPoint)

protected override ArrayPoint ArrayPointFromPoint(RectPoint point)

Parameters

point RectPoint

Returns

ArrayPoint

ArrayPointFromPoint(int, int)

protected override ArrayPoint ArrayPointFromPoint(int x, int y)

Parameters

x int
y int

Returns

ArrayPoint

BeginShape()

Use this method to begin a shape building sequence.

public static RectOp<TCell> BeginShape()

Returns

RectOp<TCell>

CalculateStorage(IEnumerable<RectPoint>)

public static IntRect CalculateStorage(IEnumerable<RectPoint> points)

Parameters

points IEnumerable<RectPoint>

Returns

IntRect

CheckerBoard(int, int)

public static RectGrid<TCell> CheckerBoard(int width, int height)

Parameters

width int
height int

Returns

RectGrid<TCell>

CheckerBoard(int, int, bool)

public static RectGrid<TCell> CheckerBoard(int width, int height, bool includesOrigin)

Parameters

width int
height int
includesOrigin bool

Returns

RectGrid<TCell>

Circle(int)

public static RectGrid<TCell> Circle(int radius)

Parameters

radius int

Returns

RectGrid<TCell>

CloneStructure<TNewCellType>()

Returns a grid in the same shape, but with contents in the new type.

public override IGrid<TNewCellType, RectPoint> CloneStructure<TNewCellType>()

Returns

IGrid<TNewCellType, RectPoint>

Type Parameters

TNewCellType

Default(int, int)

public static RectGrid<TCell> Default(int width, int height)

Parameters

width int
height int

Returns

RectGrid<TCell>

DefaultContains(RectPoint, int, int)

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

Parameters

point RectPoint
width int
height int

Returns

bool

FixedHeight(int, int)

public static RectGrid<TCell> FixedHeight(int height, int cellCount)

Parameters

height int
cellCount int

Returns

RectGrid<TCell>

FixedWidth(int, int)

public static RectGrid<TCell> FixedWidth(int width, int cellCount)

Parameters

width int
cellCount int

Returns

RectGrid<TCell>

GetPrincipleNeighborDirections()

Returns the neighbors so that no two are in the same line. For example, if East is among them, then West won't be.

public IEnumerable<RectPoint> GetPrincipleNeighborDirections()

Returns

IEnumerable<RectPoint>

GetSpiralIterator(RectPoint, int)

[Version(1, 8, 0)]
public IEnumerable<RectPoint> GetSpiralIterator(RectPoint origin, int ringCount)

Parameters

origin RectPoint
ringCount int

Returns

IEnumerable<RectPoint>

GetSpiralIterator(int)

[Version(1, 10, 0)]
public IEnumerable<RectPoint> GetSpiralIterator(int ringCount)

Parameters

ringCount int

Returns

IEnumerable<RectPoint>

GridPointFromArrayPoint(ArrayPoint)

public static RectPoint GridPointFromArrayPoint(ArrayPoint point)

Parameters

point ArrayPoint

Returns

RectPoint

HorizontallyWrappedParallelogram(int, int)

Returns a grid wrapped horizontally along a parallelogram.

Since version 1.7

public static WrappedGrid<TCell, RectPoint> HorizontallyWrappedParallelogram(int width, int height)

Parameters

width int
height int

Returns

WrappedGrid<TCell, RectPoint>

MakeEdgeGrid<TNewCell>()

Makes an edge grid for this grid.

public IGrid<TNewCell, DiamondPoint> MakeEdgeGrid<TNewCell>()

Returns

IGrid<TNewCell, DiamondPoint>

Type Parameters

TNewCell

MakeVertexGrid<TNewCell>()

Makes a grid that corresponds to the vertices of this grid.

If point is inside this grid, then all of point.GetVertices() are in the grid returned by this method.

public IGrid<TNewCell, RectPoint> MakeVertexGrid<TNewCell>()

Returns

IGrid<TNewCell, RectPoint>

Type Parameters

TNewCell

Parallelogram(int, int)

public static RectGrid<TCell> Parallelogram(int width, int height)

Parameters

width int
height int

Returns

RectGrid<TCell>

PointFromArrayPoint(int, int)

protected override RectPoint PointFromArrayPoint(int x, int y)

Parameters

x int
y int

Returns

RectPoint

Rectangle(int, int)

public static RectGrid<TCell> Rectangle(int width, int height)

Parameters

width int
height int

Returns

RectGrid<TCell>

SetNeighborsDiagonals()

public void SetNeighborsDiagonals()

SetNeighborsMain()

public void SetNeighborsMain()

SetNeighborsMainAndDiagonals()

public void SetNeighborsMainAndDiagonals()

Single()

public static RectGrid<TCell> Single()

Returns

RectGrid<TCell>

ToString()

public override string ToString()

Returns

string

VerticallyWrappedParallelogram(int, int)

Returns a grid wrapped vertically along a parallelogram.

Since version 1.7

public static WrappedGrid<TCell, RectPoint> VerticallyWrappedParallelogram(int width, int height)

Parameters

width int
height int

Returns

WrappedGrid<TCell, RectPoint>

WrappedParallelogram(int, int)

Returns a grid wrapped along a parallelogram.

Since version 1.7

public static WrappedGrid<TCell, RectPoint> WrappedParallelogram(int width, int height)

Parameters

width int
height int

Returns

WrappedGrid<TCell, RectPoint>