Class MaskModifier
Filters the cells in the the grid to a customizable subset.
Filtered cells will not be returned by GetCells, TryMove, etc. Passing them as inputs
is undefined.
Calling Unbounded will remove this modifier (as well as any bounds)
Assembly: Sylves.dll
Syntax
public class MaskModifier : BaseModifier, IGrid
Constructors
MaskModifier(IGrid, ISet<Cell>)
Declaration
public MaskModifier(IGrid underlying, ISet<Cell> allCells)
Parameters
MaskModifier(IGrid, Func<Cell, bool>, IEnumerable<Cell>)
Declaration
public MaskModifier(IGrid underlying, Func<Cell, bool> containsFunc, IEnumerable<Cell> allCells = null)
Parameters
Properties
IsFinite
True if there is a finite amout of cells in the grid.
Declaration
public override bool IsFinite { get; }
Property Value
Overrides
Unbounded
Returns the grid with any bounds removed.
Declaration
public override IGrid Unbounded { get; }
Property Value
Overrides
Methods
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
GetCells()
Gets a full list of cells in bounds.
Declaration
public override IEnumerable<Cell> GetCells()
Returns
Overrides
GetCellsInBounds(IBound)
Returns the cells inside a given bound.
Declaration
public override IEnumerable<Cell> GetCellsInBounds(IBound bound)
Parameters
| Type |
Name |
Description |
| IBound |
bound |
|
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
GetCompactGrid()
For a grid that has CoordinateDimension == 3,
returns a grid that is the same as the current, but uses at most 2 dimensions.
Otherwise, returns the current grid.
(see RavelModifier if you want to reduce to 1 dimension).
Declaration
public override IGrid GetCompactGrid()
Returns
Overrides
GetDual()
Returns a second grid which has one cell for every vertex of this grid,
and also methods for mapping corners of one grid to the other.
Declaration
public override IDualMapping GetDual()
Returns
Overrides
IsCellInBound(Cell, IBound)
Tests if a given cell is in bound.
i.e. returns true if the cell is listed in GetCellsInBounds.
Declaration
public override bool IsCellInBound(Cell cell, IBound bound)
Parameters
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
ParallelTransport(IGrid, Cell, Cell, Cell, CellRotation, out Cell, out CellRotation)
Given a path in aGrid from aSrcCell to aDestCell
follows the same path in the current grid, starting at srcCell, and with the whole path rotated by startRotation.
Reports the final spot that the path ends at, and it's rotation.
Returns false if this cannot be done (typically because an equivalent pathc annot be found in the grid).
This method is useful for translating co-ordinates between different grids that are similarish, at least having the same celltypes.
For example, suppose
aGrid = new SquareGrid(1);
aSrcCell = new Cell(0, 0)
aDestCell = new Cell(5, 0)
srcCell = new Cell(100, 100)
startRotation = identity
Then the path in aGrid is a straight line moving 5 units to the right,
and this method would attempt to move 5 units in the straight line that leads right out of (100, 100).
Declaration
public override bool ParallelTransport(IGrid aGrid, Cell aSrcCell, Cell aDestCell, Cell srcCell, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Returns
Overrides
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
Rebind(IGrid)
Creates a new grid applying the current wrapper to a new underlying.
Declaration
protected override IGrid Rebind(IGrid underlying)
Parameters
| Type |
Name |
Description |
| IGrid |
underlying |
|
Returns
Overrides
TryApplySymmetry(GridSymmetry, Cell, out Cell, out CellRotation)
Applies the mapping of s to cell, and also returns the rotation
For more details, see GridSymmetry.
For simple, regular grids, the output rotation is copied directly from Rotation.
Declaration
public override bool TryApplySymmetry(GridSymmetry s, Cell src, out Cell dest, out CellRotation r)
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
TryMoveByOffset(Cell, Vector3Int, Vector3Int, CellRotation, out Cell, out CellRotation)
Maps between cell offsets and cells in the grid.
This is normally done via FindBasicPath(Cell, Cell), but regular grids
often have a more efficient implementation.
Declaration
public override bool TryMoveByOffset(Cell startCell, Vector3Int startOffset, Vector3Int destOffset, CellRotation startRotation, out Cell destCell, out CellRotation destRotation)
Parameters
Returns
Overrides
Implements
Extension Methods