Class NestedRectGrid<TCell>
Represents a composite grid, where each cell contains a grid.
Big points access the "big" cells(which contain grids). Small points access the cells of the grids in the big cells.
The grid can also be accessed with "normal" points.For example: suppose the grid is a 3x3 grid, where each cell is a 2x2 grid. Then the "normal" point[7, 2] corresponds to "big" point[3, 1] and "small" point[1, 1].
[Version(1, 8, 0)]
public class NestedRectGrid<TCell> : IGrid<TCell, RectPoint>, IGrid<RectPoint>, IGridSpace<RectPoint>, IEnumerable<RectPoint>, IEnumerable
Type Parameters
TCell
- Inheritance
-
NestedRectGrid<TCell>
- Implements
- Inherited Members
- Extension Methods
Remarks
@note This class is likely to be redesigned when other nested grids are introduced, and could possibly be renamed.
(This class was indeed renamed in 1.8, and replaces SuperRectGrid that was introduced in 1.6.)
Constructors
NestedRectGrid(RectPoint, RectPoint)
Constructs a new NestedRectGrid.
public NestedRectGrid(RectPoint bigDimensions, RectPoint smallDimensions)
Parameters
bigDimensionsRectPointHow wide and high this grid is (how many grids per row and how many grids per column).
smallDimensionsRectPointHow wide and high each small grid is (how many cells in each row and columns).
Properties
BaseGrid
public IGridSpace<RectPoint> BaseGrid { get; }
Property Value
this[RectPoint]
Gets and sets the cell at the given normal point.
public TCell this[RectPoint point] { get; set; }
Parameters
pointRectPoint
Property Value
- TCell
this[RectPoint, RectPoint]
Gets the cell at the point that corresponds with the given big point and small point.
public TCell this[RectPoint bigPoint, RectPoint smallPoint] { get; set; }
Parameters
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, RectPoint> CloneStructure<TNewCell>()
Returns
Type Parameters
TNewCell
CombinePoints(RectPoint, RectPoint)
Gets the normal point that corresponds with the given big point and small point.
public RectPoint CombinePoints(RectPoint bigPoint, RectPoint smallPoint)
Parameters
Returns
Contains(RectPoint)
Returns whether a point is inside the grid.
public bool Contains(RectPoint point)
Parameters
pointRectPoint
Returns
Remarks
Use this method to control the shape of the grid.
GetAllNeighbors(RectPoint)
Returns the neighbors of this point, regardless of whether they are in the grid or not.
public IEnumerable<RectPoint> GetAllNeighbors(RectPoint point)
Parameters
pointRectPoint
Returns
GetBigPoint(RectPoint)
Gets the big point that corresponds to the given normal point.
public RectPoint GetBigPoint(RectPoint point)
Parameters
pointRectPoint
Returns
GetEnumerator()
public IEnumerator<RectPoint> 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<RectPoint> GetLargeSet(int n)
Parameters
nint
Returns
GetSmallGrid(RectPoint)
public RectGrid<TCell> GetSmallGrid(RectPoint bigPoint)
Parameters
bigPointRectPoint
Returns
- RectGrid<TCell>
GetSmallPoint(RectPoint)
Gets the small point that corresponds to the given normal point.
public RectPoint GetSmallPoint(RectPoint point)
Parameters
pointRectPoint
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<RectPoint> GetStoragePoints()
Returns
GetValue(RectPoint, RectPoint)
Get the value at the given big point and small point within the cell at the big point.
public TCell GetValue(RectPoint bigPoint, RectPoint smallPoint)
Parameters
Returns
- TCell