Class WrappedGrid<TCell, TPoint>
A general implementation of Wrapped grids, that use arbitrary internal grids and point wrappers.
A "true point" of a wrapped grid is a point that stays the same after the wrapping.
- Contains returns true only for true points.
- GetAllNeighbors return true points (that is, the neighbors are already wrapped)
- the index operator takes all points, and wrap them before access
- Iterators iterate over true points
[Version(1, 7, 0)]
public class WrappedGrid<TCell, TPoint> : IGrid<TCell, TPoint>, IGrid<TPoint>, IGridSpace<TPoint>, IEnumerable<TPoint>, IEnumerable where TPoint : IGridPoint<TPoint>
Type Parameters
TCell
TPoint
- Inheritance
-
WrappedGrid<TCell, TPoint>
- Implements
-
IGrid<TCell, TPoint>IGrid<TPoint>IGridSpace<TPoint>IEnumerable<TPoint>
- Inherited Members
- Extension Methods
Constructors
WrappedGrid(IGrid<TCell, TPoint>, IPointWrapper<TPoint>)
public WrappedGrid(IGrid<TCell, TPoint> grid, IPointWrapper<TPoint> wrapper)
Parameters
grid
IGrid<TCell, TPoint>wrapper
IPointWrapper<TPoint>
Properties
this[TPoint]
Points are wrapped before the queries are performed.
public TCell this[TPoint point] { get; set; }
Parameters
point
TPoint
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, TPoint> CloneStructure<TNewCell>()
Returns
- IGrid<TNewCell, TPoint>
Type Parameters
TNewCell
Contains(TPoint)
This method returns whether the grid contains the unwrapped point or not.
public bool Contains(TPoint point)
Parameters
point
TPoint
Returns
GetAllNeighbors(TPoint)
Returns all neighbors in this grid as wrapped points.
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 because of an incorrect test function, or an incorrect storage rectangle.
Use for debugging.
public IEnumerable<TPoint> GetLargeSet(int n)
Parameters
n
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.
public IEnumerable<TPoint> GetStoragePoints()
Returns
- IEnumerable<TPoint>
Wrap(TPoint)
public TPoint Wrap(TPoint point)
Parameters
point
TPoint
Returns
- TPoint