Class AbstractSplicedGrid<TCell, TPoint, TBasePoint>
A spliced grid represents a simple grid where all cells has been sliced in an equal numbers of cells. This class implements the common features of tri and rhomb grids. It is the most probable class to use to define your own grid.
[Version(1, 0, 0)]
[Serializable]
public abstract class AbstractSplicedGrid<TCell, TPoint, TBasePoint> : IGrid<TCell, TPoint>, IGrid<TPoint>, IGridSpace<TPoint>, IEnumerable<TPoint>, IEnumerable where TPoint : ISplicedPoint<TPoint, TBasePoint> where TBasePoint : IGridPoint<TBasePoint>, IVectorPoint<TBasePoint>
Type Parameters
TCell
TPoint
TBasePoint
- Inheritance
-
AbstractSplicedGrid<TCell, TPoint, TBasePoint>
- Implements
-
IGrid<TCell, TPoint>IGrid<TPoint>IGridSpace<TPoint>IEnumerable<TPoint>
- Derived
- Inherited Members
- Extension Methods
Constructors
AbstractSplicedGrid(int, int, int, Func<TPoint, bool>, Func<TPoint, TPoint>, Func<TPoint, TPoint>, IEnumerable<TPoint>[])
protected AbstractSplicedGrid(int width, int height, int cellDivisionCount, Func<TPoint, bool> isInsideTest, Func<TPoint, TPoint> gridPointTransform, Func<TPoint, TPoint> inverseGridPointTransform, IEnumerable<TPoint>[] neighborDirections)
Parameters
width
intheight
intcellDivisionCount
intisInsideTest
Func<TPoint, bool>gridPointTransform
Func<TPoint, TPoint>inverseGridPointTransform
Func<TPoint, TPoint>neighborDirections
IEnumerable<TPoint>[]
Fields
contains
[NonSerialized]
protected Func<TPoint, bool> contains
Field Value
height
protected int height
Field Value
neighborDirections
protected IEnumerable<TPoint>[] neighborDirections
Field Value
- IEnumerable<TPoint>[]
width
protected int width
Field Value
Properties
GridOrigin
Gives the Zero point as transform by this grids transforms.
protected abstract TPoint GridOrigin { get; }
Property Value
- TPoint
InversePointTransform
protected Func<TPoint, TPoint> InversePointTransform { get; }
Property Value
- Func<TPoint, TPoint>
this[TPoint]
Accesses a cell in the given point.
public TCell this[TPoint point] { get; set; }
Parameters
point
TPoint
Property Value
- TCell
NeighborDirections
public IEnumerable<TPoint>[] NeighborDirections { get; set; }
Property Value
- IEnumerable<TPoint>[]
PointTransform
protected Func<TPoint, TPoint> PointTransform { get; }
Property Value
- Func<TPoint, TPoint>
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 abstract IGrid<TNewCell, TPoint> CloneStructure<TNewCell>()
Returns
- IGrid<TNewCell, TPoint>
Type Parameters
TNewCell
Contains(TPoint)
Returns whether a point is inside the grid.
public bool Contains(TPoint point)
Parameters
point
TPoint
Returns
Remarks
Use this method to control the shape of the grid.
GetAllNeighbors(TPoint)
Returns the neighbors of this point, regardless of whether they are in the grid or not.
public IEnumerable<TPoint> GetAllNeighbors(TPoint point)
Parameters
point
TPoint
Returns
- IEnumerable<TPoint>
GetEnumerator()
public IEnumerator<TPoint> GetEnumerator()
Returns
- IEnumerator<TPoint>
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 becuase of an incorrect test function, or an incorrect storage rectangle.
Use for debugging.
[Version(1, 1, 0)]
public IEnumerable<TPoint> GetLargeSet(int n)
Parameters
n
int
Returns
- IEnumerable<TPoint>
GetNeighborDirections(int)
public IEnumerable<TPoint> GetNeighborDirections(int cellIndex)
Parameters
cellIndex
int
Returns
- IEnumerable<TPoint>
GetStoragePoints()
This method returns all points that can be contained by the storage rectangle for this grid. This is useful for debugging shape functions.
[Version(1, 1, 0)]
public IEnumerable<TPoint> GetStoragePoints()
Returns
- IEnumerable<TPoint>
MakePoint(TBasePoint, int)
protected abstract TPoint MakePoint(TBasePoint basePoint, int index)
Parameters
basePoint
TBasePointindex
int
Returns
- TPoint
MakeUnderlyingGrid(int, int)
protected abstract IGrid<TCell[], TBasePoint> MakeUnderlyingGrid(int width, int height)
Parameters
Returns
- IGrid<TCell[], TBasePoint>
SetGridPointTransforms(Func<TPoint, TPoint>, Func<TPoint, TPoint>)
this function make it possible to do things such as flip axes.
public void SetGridPointTransforms(Func<TPoint, TPoint> gridPointTransform, Func<TPoint, TPoint> inverseGridPointTransform)