Class SubstitutionTilingGrid
Creates a tiling of the 2d plane from a set of substitution rules.
It is quite flexible:
- imperfect substitution rules where the replacement outline doesn't follow the original outline
- tiles can freely transformed
- tile equivalence under translation, euclidian motion, isometry, similarity all supported
- "statistically round" substitutions like the pinwheel substitution supported
Inheritance
SubstitutionTilingGrid
Assembly: Sylves.dll
Syntax
public class SubstitutionTilingGrid : BaseSubstitutionTilingGrid, IGrid
Constructors
SubstitutionTilingGrid(Prototile[], Func<int, string>, SubstitutionTilingBound, ICachePolicy)
Declaration
public SubstitutionTilingGrid(Prototile[] prototiles, Func<int, string> hierarchy, SubstitutionTilingBound bound = null, ICachePolicy cachePolicy = null)
Parameters
SubstitutionTilingGrid(Prototile[], string[], SubstitutionTilingBound, ICachePolicy)
Declaration
public SubstitutionTilingGrid(Prototile[] prototiles, string[] hierarchy, SubstitutionTilingBound bound = null, ICachePolicy cachePolicy = null)
Parameters
Properties
Raw
Declaration
public RawSubstitutionTilingGrid Raw { get; }
Property Value
Unbounded
Returns the grid with any bounds removed.
Declaration
public override IGrid Unbounded { get; }
Property Value
Overrides
Methods
BoundBy(IBound)
Returns a new grid restricted to just the given bound.
If the grid already has a bound, the new grid will have the intersection of both.
Declaration
public override IGrid BoundBy(IBound bound)
Parameters
| Type |
Name |
Description |
| IBound |
bound |
|
Returns
Overrides
CellToParentGrid(Cell, int)
Declaration
public Cell CellToParentGrid(Cell cell, int n = 1)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
| int |
n |
|
Returns
FindCell(Matrix4x4, out Cell, out CellRotation)
Returns the cell and rotation corresponding to a given transform matrix.
Declaration
public override bool FindCell(Matrix4x4 matrix, out Cell cell, out CellRotation rotation)
Parameters
Returns
Overrides
FindCell(Vector3, out Cell)
Finds the cell containg the give position
Declaration
public override bool FindCell(Vector3 position, out Cell cell)
Parameters
Returns
Overrides
GetCellCenter(Cell)
Returns the center of the cell in local space
Declaration
public override Vector3 GetCellCenter(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
Overrides
GetCellType(Cell)
Returns the cell type associated with a given cell
Declaration
public override ICellType GetCellType(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
Overrides
GetCellsIntersectsApprox(Vector3, Vector3)
Gets the set of cells that potentially overlap bounds.
Declaration
public override IEnumerable<Cell> GetCellsIntersectsApprox(Vector3 min, Vector3 max)
Parameters
Returns
Overrides
GetPolygon(Cell, out Vector3[], out Matrix4x4)
For 2d cells, returns the polygon of the boundary of the cell.
For performance reasons, cells can share a vertices array, so you need to apply
a specific transform to get the polygon specific to a particular cell.
Declaration
public override void GetPolygon(Cell cell, out Vector3[] vertices, out Matrix4x4 transform)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
| Vector3[] |
vertices |
The vertices of the polygon. This should not be mutated.
|
| Matrix4x4 |
transform |
A transformation that needs to be applied to each vertex.
|
Overrides
GetPrototile(Cell, int)
Declaration
protected override BaseSubstitutionTilingGrid.InternalPrototile GetPrototile(Cell cell, int height)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
| int |
height |
|
Returns
Overrides
GetPrototileName(Cell, int)
Declaration
public string GetPrototileName(Cell cell, int height = 0)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
| int |
height |
|
Returns
GetTRS(Cell)
Returns the appropriate transform for the cell.
The translation will always be to GetCellCenter,
rotation reflects the particular orientation of this cell
and the scale will reflect cell sizing.
GetTRS is often "best effort", there might not be an obvious
linear transformation from the canonical cell to the grid cell.
Declaration
public override TRS GetTRS(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
Overrides
IsCellInGrid(Cell)
Returns true if the cell is in the grid (and within bounds).
This is one of the few methods that accepts any Cell object, most
other methods only work with the cells in the grid.
Declaration
public override bool IsCellInGrid(Cell cell)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
|
Returns
Overrides
ParentGrid(int)
Declaration
public SubstitutionTilingGrid ParentGrid(int n = 1)
Parameters
| Type |
Name |
Description |
| int |
n |
|
Returns
Raycast(Vector3, Vector3, float)
Returns the cells intersecting a ray starting at origin, of length direction.magnitude * maxDistance, in order.
Declaration
public override IEnumerable<RaycastInfo> Raycast(Vector3 origin, Vector3 direction, float maxDistance = Infinity)
Parameters
Returns
Overrides
TryMove(Cell, CellDir, out Cell, out CellDir, out Connection)
Attempts to move from a cell in a given direction, and returns information about the move if successful.
Declaration
public override bool TryMove(Cell cell, CellDir dir, out Cell dest, out CellDir inverseDir, out Connection connection)
Parameters
| Type |
Name |
Description |
| Cell |
cell |
The cell to move from
|
| CellDir |
dir |
The direction to move in
|
| Cell |
dest |
The cell moved to
|
| CellDir |
inverseDir |
The direction leading back from dest to cell.
|
| Connection |
connection |
A descriptor of how cell-local space relates between cell and dest.
|
Returns
Overrides
Implements
Extension Methods