Class SplicedGrid<TCell, TBasePoint>
A SplicedGrid is a grid formed from another grid, where each cell is "spliced" in a certain number of cells. For example, a triangular grid can be implemented as a diamond grid where each diamond cell is spliced into two triangles.
public class SplicedGrid<TCell, TBasePoint> : IGrid<TCell, SplicedPoint<TBasePoint>>, IGrid<SplicedPoint<TBasePoint>>, IGridSpace<SplicedPoint<TBasePoint>>, IEnumerable<SplicedPoint<TBasePoint>>, IEnumerable where TBasePoint : IGridPoint<TBasePoint>
Type Parameters
TCellTBasePoint
- Inheritance
-
SplicedGrid<TCell, TBasePoint>
- Implements
-
IGrid<TCell, SplicedPoint<TBasePoint>>IGrid<SplicedPoint<TBasePoint>>IGridSpace<SplicedPoint<TBasePoint>>IEnumerable<SplicedPoint<TBasePoint>>
- Inherited Members
- Extension Methods
Constructors
SplicedGrid(IGrid<TBasePoint>, int)
Constructs a new spliced grid from the given base grid, where each cell is divided into the number of splices given.
public SplicedGrid(IGrid<TBasePoint> model, int spliceCount)
Parameters
Properties
this[SplicedPoint<TBasePoint>]
Accesses a cell in the given point.
public TCell this[SplicedPoint<TBasePoint> point] { get; set; }
Parameters
pointSplicedPoint<TBasePoint>
Property Value
- TCell
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
CloneStructure<TNewCell>()
Returns a grid with exactly the same structure, but potentially holding elements of a different type.
public IGrid<TNewCell, SplicedPoint<TBasePoint>> CloneStructure<TNewCell>()
Returns
- IGrid<TNewCell, SplicedPoint<TBasePoint>>
Type Parameters
TNewCell
Contains(SplicedPoint<TBasePoint>)
Returns whether a point is inside the grid.
public bool Contains(SplicedPoint<TBasePoint> point)
Parameters
pointSplicedPoint<TBasePoint>
Returns
Remarks
Use this method to control the shape of the grid.
GetAllNeighbors(SplicedPoint<TBasePoint>)
Returns the neighbors of this point, regardless of whether they are in the grid or not.
public IEnumerable<SplicedPoint<TBasePoint>> GetAllNeighbors(SplicedPoint<TBasePoint> point)
Parameters
pointSplicedPoint<TBasePoint>
Returns
- IEnumerable<SplicedPoint<TBasePoint>>
GetEnumerator()
public IEnumerator<SplicedPoint<TBasePoint>> GetEnumerator()
Returns
- IEnumerator<SplicedPoint<TBasePoint>>
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<SplicedPoint<TBasePoint>> GetLargeSet(int n)
Parameters
nint
Returns
- IEnumerable<SplicedPoint<TBasePoint>>
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<SplicedPoint<TBasePoint>> GetStoragePoints()
Returns
- IEnumerable<SplicedPoint<TBasePoint>>