Table of Contents

Class PointyHexGrid<TCell>

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

A grid for pointy hexagons, that is, hexagons with two vertical edges.

[Version(1, 0, 0)]
[Serializable]
public class PointyHexGrid<TCell> : AbstractUniformGrid<TCell, PointyHexPoint>, IEvenGrid<TCell, PointyHexPoint, PointyHexPoint>, IVectorGrid<TCell, PointyHexPoint, PointyHexPoint>, IGrid<TCell, PointyHexPoint>, IGrid<PointyHexPoint>, IGridSpace<PointyHexPoint>, IEnumerable<PointyHexPoint>, IEnumerable, ISupportsVertexGrid<FlatTriPoint>, ISupportsEdgeGrid<PointyRhombPoint>

Type Parameters

TCell
Inheritance
PointyHexGrid<TCell>
Implements
Inherited Members
Extension Methods

Constructors

PointyHexGrid(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 PointyHexGrid(int width, int height)

Parameters

width int
height int

PointyHexGrid(int, int, Func<PointyHexPoint, 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 PointyHexGrid(int width, int height, Func<PointyHexPoint, bool> isInside)

Parameters

width int
height int
isInside Func<PointyHexPoint, bool>

PointyHexGrid(int, int, Func<PointyHexPoint, bool>, PointyHexPoint)

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 PointyHexGrid(int width, int height, Func<PointyHexPoint, bool> isInside, PointyHexPoint offset)

Parameters

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

PointyHexGrid(int, int, Func<PointyHexPoint, bool>, Func<PointyHexPoint, PointyHexPoint>, Func<PointyHexPoint, PointyHexPoint>)

public PointyHexGrid(int width, int height, Func<PointyHexPoint, bool> isInside, Func<PointyHexPoint, PointyHexPoint> gridPointTransform, Func<PointyHexPoint, PointyHexPoint> inverseGridPointTransform)

Parameters

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

PointyHexGrid(int, int, Func<PointyHexPoint, bool>, Func<PointyHexPoint, PointyHexPoint>, Func<PointyHexPoint, PointyHexPoint>, IEnumerable<PointyHexPoint>)

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

Parameters

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

Properties

GridOrigin

Gives the Zero point as transform by this grids transforms.

protected override PointyHexPoint GridOrigin { get; }

Property Value

PointyHexPoint

Methods

ArrayPointFromGridPoint(PointyHexPoint)

public static ArrayPoint ArrayPointFromGridPoint(PointyHexPoint point)

Parameters

point PointyHexPoint

Returns

ArrayPoint

ArrayPointFromPoint(PointyHexPoint)

protected override ArrayPoint ArrayPointFromPoint(PointyHexPoint hexPoint)

Parameters

hexPoint PointyHexPoint

Returns

ArrayPoint

ArrayPointFromPoint(int, int)

protected override ArrayPoint ArrayPointFromPoint(int hX, int hY)

Parameters

hX int
hY int

Returns

ArrayPoint

BeginShape()

Use this method to begin a shape building sequence.

public static PointyHexOp<TCell> BeginShape()

Returns

PointyHexOp<TCell>

CalculateStorage(IEnumerable<PointyHexPoint>)

public static IntRect CalculateStorage(IEnumerable<PointyHexPoint> points)

Parameters

points IEnumerable<PointyHexPoint>

Returns

IntRect

CloneStructure<TNewCellType>()

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

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

Returns

IGrid<TNewCellType, PointyHexPoint>

Type Parameters

TNewCellType

Default(int, int)

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

Parameters

width int
height int

Returns

PointyHexGrid<TCell>

DefaultContains(PointyHexPoint, int, int)

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

Parameters

point PointyHexPoint
width int
height int

Returns

bool

Diamond(int)

public static PointyHexGrid<TCell> Diamond(int side)

Parameters

side int

Returns

PointyHexGrid<TCell>

DownTriangle(int)

public static PointyHexGrid<TCell> DownTriangle(int side)

Parameters

side int

Returns

PointyHexGrid<TCell>

FatRectangle(int, int)

public static PointyHexGrid<TCell> FatRectangle(int width, int height)

Parameters

width int
height int

Returns

PointyHexGrid<TCell>

GetPrincipleNeighborDirections()

This is the set of neighbor directions so that it contains only one of the neighbor directions of a pair of opposites.

public IEnumerable<PointyHexPoint> GetPrincipleNeighborDirections()

Returns

IEnumerable<PointyHexPoint>

GetSpiralIterator(PointyHexPoint, int)

An iterator that spirals anti-clockwise around the given origin.

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

Parameters

origin PointyHexPoint
ringCount int

Returns

IEnumerable<PointyHexPoint>

Examples

int k = 0;

foreach(var point in grid.GetSpiralIterator(point, 3))
{
	grid[point].name = k.ToString();
}

GetSpiralIterator(int)

An iterator that spirals anti-clockwise around the grid origin (0, 0).

[Version(1, 7, 0)]
public IEnumerable<PointyHexPoint> GetSpiralIterator(int ringCount)

Parameters

ringCount int

Returns

IEnumerable<PointyHexPoint>

GridPointFromArrayPoint(ArrayPoint)

public static PointyHexPoint GridPointFromArrayPoint(ArrayPoint point)

Parameters

point ArrayPoint

Returns

PointyHexPoint

Hexagon(PointyHexPoint, int)

public static PointyHexGrid<TCell> Hexagon(PointyHexPoint centre, int side)

Parameters

centre PointyHexPoint
side int

Returns

PointyHexGrid<TCell>

Hexagon(int)

public static PointyHexGrid<TCell> Hexagon(int side)

Parameters

side int

Returns

PointyHexGrid<TCell>

HorizontallyWrappedParallelogram(int, int)

Returns a grid wrapped horizontally along a parallelogram.

Since version 1.7

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

Parameters

width int
height int

Returns

WrappedGrid<TCell, PointyHexPoint>

HorizontallyWrappedRectangle(int, int)

Returns a grid wrapped horizontally along a parallelogram.

[Version(1, 7, 0)]
public static WrappedGrid<TCell, PointyHexPoint> HorizontallyWrappedRectangle(int width, int height)

Parameters

width int
height int

Returns

WrappedGrid<TCell, PointyHexPoint>

MakeEdgeGrid<TNewCell>()

Makes an edge grid for this grid.

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

Returns

IGrid<TNewCell, PointyRhombPoint>

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, FlatTriPoint> MakeVertexGrid<TNewCell>()

Returns

IGrid<TNewCell, FlatTriPoint>

Type Parameters

TNewCell

Parallelogram(int, int)

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

Parameters

width int
height int

Returns

PointyHexGrid<TCell>

PointFromArrayPoint(int, int)

protected override PointyHexPoint PointFromArrayPoint(int aX, int aY)

Parameters

aX int
aY int

Returns

PointyHexPoint

Rectangle(int, int)

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

Parameters

width int
height int

Returns

PointyHexGrid<TCell>

Single()

public static PointyHexGrid<TCell> Single()

Returns

PointyHexGrid<TCell>

ThinRectangle(int, int)

public static PointyHexGrid<TCell> ThinRectangle(int width, int height)

Parameters

width int
height int

Returns

PointyHexGrid<TCell>

ToString()

public override string ToString()

Returns

string

UpTriangle(int)

public static PointyHexGrid<TCell> UpTriangle(int side)

Parameters

side int

Returns

PointyHexGrid<TCell>

VerticallyWrappedParallelogram(int, int)

Returns a grid wrapped vertically along a parallelogram.

Since version 1.7

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

Parameters

width int
height int

Returns

WrappedGrid<TCell, PointyHexPoint>

WrappedHexagon(int)

Returns a new grid, wrapped along a Hexagon with the given side length.

[Version(1, 7, 0)]
public static WrappedGrid<TCell, PointyHexPoint> WrappedHexagon(int side)

Parameters

side int

Returns

WrappedGrid<TCell, PointyHexPoint>

WrappedParallelogram(int, int)

Returns a grid wrapped along a parallelogram.

Since version 1.7

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

Parameters

width int
height int

Returns

WrappedGrid<TCell, PointyHexPoint>