Class DictionaryGrid<TCell, TPoint>
public class DictionaryGrid<TCell, TPoint> : IGrid<TCell, TPoint>, IGrid<TPoint>, IGridSpace<TPoint>, IEnumerable<TPoint>, IEnumerable where TPoint : IGridPoint<TPoint>
Type Parameters
TCell
TPoint
- Inheritance
-
DictionaryGrid<TCell, TPoint>
- Implements
-
IGrid<TCell, TPoint>IGrid<TPoint>IGridSpace<TPoint>IEnumerable<TPoint>
- Inherited Members
- Extension Methods
Constructors
DictionaryGrid(IEnumerable<TPoint>)
public DictionaryGrid(IEnumerable<TPoint> points)
Parameters
points
IEnumerable<TPoint>
Properties
this[TPoint]
Accesses a cell in the given point.
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)
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 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>