Class LineGrid<TCell>
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
intisInsideTest
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
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
intdummy
intisInsideTest
Func<LinePoint, bool>gridPointTransform
Func<LinePoint, LinePoint>inverseGridPointTransform
Func<LinePoint, LinePoint>neighborDirections
IEnumerable<LinePoint>
Fields
DefaultNeighborDirections
protected static readonly LinePoint[] DefaultNeighborDirections
Field Value
contains
protected Func<LinePoint, bool> contains
Field Value
Properties
InversePointTransform
protected Func<LinePoint, LinePoint> InversePointTransform { get; }
Property Value
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
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
Type Parameters
TNewCell
Contains(LinePoint)
Returns whether a point is inside the grid.
public bool Contains(LinePoint point)
Parameters
point
LinePoint
Returns
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
Returns
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
GetEnumerator()
public IEnumerator<LinePoint> GetEnumerator()
Returns
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
GetNeighborDirections(int)
public IEnumerable<LinePoint> GetNeighborDirections(int cellIndex)
Parameters
cellIndex
int
Returns
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
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)