Table of Contents

Class FlatHexOp<TCell>

Namespace
Gamelogic.Grids
Assembly
Assembly-CSharp.dll

Documentation in Op.cs

public class FlatHexOp<TCell> : AbstractOp<ShapeStorageInfo<FlatHexPoint>>

Type Parameters

TCell
Inheritance
FlatHexOp<TCell>
Inherited Members
Extension Methods

Constructors

FlatHexOp()

public FlatHexOp()

FlatHexOp(ShapeStorageInfo<FlatHexPoint>, Func<ShapeStorageInfo<FlatHexPoint>, ShapeStorageInfo<FlatHexPoint>, ShapeStorageInfo<FlatHexPoint>>)

public FlatHexOp(ShapeStorageInfo<FlatHexPoint> leftShapeInfo, Func<ShapeStorageInfo<FlatHexPoint>, ShapeStorageInfo<FlatHexPoint>, ShapeStorageInfo<FlatHexPoint>> combineShapeInfo)

Parameters

leftShapeInfo ShapeStorageInfo<FlatHexPoint>
combineShapeInfo Func<ShapeStorageInfo<FlatHexPoint>, ShapeStorageInfo<FlatHexPoint>, ShapeStorageInfo<FlatHexPoint>>

Methods

BeginGroup()

Starts a compound shape operation.

Any shape that is defined in terms of other shape operations must use this method, and use Endgroup() to end the definition.
public static FlatHexShapeInfo<TCell> MyCustomShape(this FlatHexOp<TCell> op)
{
	return 
		BeginGroup()
			.Shape1()
			.Union()
			.Shape2()
		.EndGroup(op);
}
Since version 1.1
public FlatHexOp<TCell> BeginGroup()

Returns

FlatHexOp<TCell>

Default(int, int)

Creates the grid in a shape that spans the entire storage rectangle of the given width and height.

public FlatHexShapeInfo<TCell> Default(int width, int height)

Parameters

width int
height int

Returns

FlatHexShapeInfo<TCell>

Diamond(int)

Bottom corner is the origin.

public FlatHexShapeInfo<TCell> Diamond(int side)

Parameters

side int

Returns

FlatHexShapeInfo<TCell>

FatRectangle(int, int)

Bottom left corner is the origin.

public FlatHexShapeInfo<TCell> FatRectangle(int width, int height)

Parameters

width int
height int

Returns

FlatHexShapeInfo<TCell>

Hexagon(FlatHexPoint, int)

Bottom corner is the origin.

public FlatHexShapeInfo<TCell> Hexagon(FlatHexPoint centre, int side)

Parameters

centre FlatHexPoint
side int

Returns

FlatHexShapeInfo<TCell>

Hexagon(int)

Center is the origin.

public FlatHexShapeInfo<TCell> Hexagon(int side)

Parameters

side int

Returns

FlatHexShapeInfo<TCell>

LeftTriangle(int)

Bottom corner is the origin.

public FlatHexShapeInfo<TCell> LeftTriangle(int side)

Parameters

side int

Returns

FlatHexShapeInfo<TCell>

Parallelogram(int, int)

Bottom corner is the origin.

public FlatHexShapeInfo<TCell> Parallelogram(int width, int height)

Parameters

width int
height int

Returns

FlatHexShapeInfo<TCell>

Rectangle(int, int)

Bottom left corner is the origin.

public FlatHexShapeInfo<TCell> Rectangle(int width, int height)

Parameters

width int
height int

Returns

FlatHexShapeInfo<TCell>

RightTriangle(int)

Bottom corner is the origin.

public FlatHexShapeInfo<TCell> RightTriangle(int side)

Parameters

side int

Returns

FlatHexShapeInfo<TCell>

Shape(int, int, Func<FlatHexPoint, bool>)

The same as Shape with all parameters, but with bottomLeft Point set to FlatHexPoint.Zero.

public FlatHexShapeInfo<TCell> Shape(int width, int height, Func<FlatHexPoint, bool> isInside)

Parameters

width int
height int
isInside Func<FlatHexPoint, bool>

Returns

FlatHexShapeInfo<TCell>

Shape(int, int, Func<FlatHexPoint, bool>, FlatHexPoint)

Use this function to create shapes to ensure they fit into memory.

The test function can test shapes anywhere in space.If you specify the bottom corner (in terms of the storage rectangle), the shape is automatically translated in memory to fit, assuming memory width and height is big enough.

Strategy for implementing new shapes: - First, determine the test function. - Next, draw a storage rectangle that contains the shape. - Determine the storgae rectangle width and height. - Finally, determine the grid-space coordinate of the left bottom corner of the storage rectangle.

Then define your function as follows:

public FlatHexShapeInfo<TCell> MyShape()
{
	Shape(stargeRectangleWidth, storageRectangleHeight, isInsideMyShape, storageRectangleBottomleft);
}
public FlatHexShapeInfo<TCell> Shape(int width, int height, Func<FlatHexPoint, bool> isInside, FlatHexPoint bottomLeftCorner)

Parameters

width int

The widh of the storage rectangle

height int

The height of the storage rectangle

isInside Func<FlatHexPoint, bool>

A function that returns true if a passed point lies inside the shape being defined

bottomLeftCorner FlatHexPoint

The grid-space coordinate of the bottom left corner of the storage rect.

Returns

FlatHexShapeInfo<TCell>

Single()

Makes a grid with a single cell that corresponds to the origin.

public FlatHexShapeInfo<TCell> Single()

Returns

FlatHexShapeInfo<TCell>

ThinRectangle(int, int)

Bottom left corner is the origin.

public FlatHexShapeInfo<TCell> ThinRectangle(int width, int height)

Parameters

width int
height int

Returns

FlatHexShapeInfo<TCell>