Show / Hide Table of Contents

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)

Inheritance
object
BaseModifier
MaskModifier
Implements
IGrid
Inherited Members
BaseModifier.GetCellTypes()
BaseModifier.GetDiagonalGrid()
BaseModifier.Recenter(Cell)
BaseModifier.GetCellType(Cell)
BaseModifier.GetCellDirs(Cell)
BaseModifier.GetCellCorners(Cell)
BaseModifier.FindBasicPath(Cell, Cell)
BaseModifier.GetIndex(Cell)
BaseModifier.GetCellByIndex(int)
BaseModifier.GetBound()
BaseModifier.GetBound(IEnumerable<Cell>)
BaseModifier.BoundBy(IBound)
BaseModifier.IntersectBounds(IBound, IBound)
BaseModifier.UnionBounds(IBound, IBound)
BaseModifier.GetBoundAabb(IBound)
BaseModifier.GetCellCenter(Cell)
BaseModifier.GetCellCorner(Cell, CellCorner)
BaseModifier.GetTRS(Cell)
BaseModifier.GetDeformation(Cell)
BaseModifier.GetPolygon(Cell, out Vector3[], out Matrix4x4)
BaseModifier.GetTriangleMesh(Cell)
BaseModifier.GetMeshData(Cell, out MeshData, out Matrix4x4)
BaseModifier.GetAabb(Cell)
BaseModifier.GetAabb(IEnumerable<Cell>)
BaseModifier.FindGridSymmetry(ISet<Cell>, ISet<Cell>, Cell, CellRotation)
BaseModifier.TryApplySymmetry(GridSymmetry, IBound, out IBound)
BaseModifier.Is2d
BaseModifier.Is3d
BaseModifier.IsPlanar
BaseModifier.IsRepeating
BaseModifier.IsOrientable
BaseModifier.IsSingleCellType
BaseModifier.CoordinateDimension
BaseModifier.Unwrapped
BaseModifier.Underlying
BaseModifier.IndexCount
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
Namespace: Sylves
Assembly: Sylves.dll
Syntax
public class MaskModifier : BaseModifier, IGrid

Constructors

MaskModifier(IGrid, ISet<Cell>)

Declaration
public MaskModifier(IGrid underlying, ISet<Cell> allCells)
Parameters
Type Name Description
IGrid underlying
ISet<Cell> allCells

MaskModifier(IGrid, Func<Cell, bool>, IEnumerable<Cell>)

Declaration
public MaskModifier(IGrid underlying, Func<Cell, bool> containsFunc, IEnumerable<Cell> allCells = null)
Parameters
Type Name Description
IGrid underlying
Func<Cell, bool> containsFunc
IEnumerable<Cell> allCells

Properties

IsFinite

True if there is a finite amout of cells in the grid.

Declaration
public override bool IsFinite { get; }
Property Value
Type Description
bool
Overrides
BaseModifier.IsFinite

Unbounded

Returns the grid with any bounds removed.

Declaration
public override IGrid Unbounded { get; }
Property Value
Type Description
IGrid
Overrides
BaseModifier.Unbounded

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
Type Name Description
Matrix4x4 matrix
Cell cell
CellRotation rotation
Returns
Type Description
bool
Overrides
BaseModifier.FindCell(Matrix4x4, out Cell, out CellRotation)

FindCell(Vector3, out Cell)

Finds the cell containg the give position

Declaration
public override bool FindCell(Vector3 position, out Cell cell)
Parameters
Type Name Description
Vector3 position
Cell cell
Returns
Type Description
bool
Overrides
BaseModifier.FindCell(Vector3, out Cell)

GetCells()

Gets a full list of cells in bounds.

Declaration
public override IEnumerable<Cell> GetCells()
Returns
Type Description
IEnumerable<Cell>
Overrides
BaseModifier.GetCells()

GetCellsInBounds(IBound)

Returns the cells inside a given bound.

Declaration
public override IEnumerable<Cell> GetCellsInBounds(IBound bound)
Parameters
Type Name Description
IBound bound
Returns
Type Description
IEnumerable<Cell>
Overrides
BaseModifier.GetCellsInBounds(IBound)

GetCellsIntersectsApprox(Vector3, Vector3)

Gets the set of cells that potentially overlap bounds.

Declaration
public override IEnumerable<Cell> GetCellsIntersectsApprox(Vector3 min, Vector3 max)
Parameters
Type Name Description
Vector3 min
Vector3 max
Returns
Type Description
IEnumerable<Cell>
Overrides
BaseModifier.GetCellsIntersectsApprox(Vector3, Vector3)

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
Type Description
IGrid
Overrides
BaseModifier.GetCompactGrid()

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
Type Description
IDualMapping
Overrides
BaseModifier.GetDual()

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
Type Name Description
Cell cell
IBound bound
Returns
Type Description
bool
Overrides
BaseModifier.IsCellInBound(Cell, IBound)

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
Type Description
bool
Overrides
BaseModifier.IsCellInGrid(Cell)

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
Type Name Description
IGrid aGrid
Cell aSrcCell
Cell aDestCell
Cell srcCell
CellRotation startRotation
Cell destCell
CellRotation destRotation
Returns
Type Description
bool
Overrides
BaseModifier.ParallelTransport(IGrid, Cell, Cell, Cell, CellRotation, out Cell, out CellRotation)

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
Type Name Description
Vector3 origin
Vector3 direction
float maxDistance
Returns
Type Description
IEnumerable<RaycastInfo>
Overrides
BaseModifier.Raycast(Vector3, Vector3, float)

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
Type Description
IGrid
Overrides
BaseModifier.Rebind(IGrid)

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
Type Name Description
GridSymmetry s
Cell src
Cell dest
CellRotation r
Returns
Type Description
bool
Overrides
BaseModifier.TryApplySymmetry(GridSymmetry, Cell, out Cell, out CellRotation)

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
Type Description
bool
Overrides
BaseModifier.TryMove(Cell, CellDir, out Cell, out CellDir, out Connection)

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
Type Name Description
Cell startCell
Vector3Int startOffset
Vector3Int destOffset
CellRotation startRotation
Cell destCell
CellRotation destRotation
Returns
Type Description
bool
Overrides
BaseModifier.TryMoveByOffset(Cell, Vector3Int, Vector3Int, CellRotation, out Cell, out CellRotation)

Implements

IGrid

Extension Methods

GridExtensions.FindCell(IGrid, Vector3)
GridExtensions.GetCellsIntersectsApprox(IGrid, Aabb)
GridExtensions.GetMeshData(IGrid, Cell)
GridExtensions.GetNeighbours(IGrid, Cell)
GridExtensions.GetPolygon(IGrid, Cell)
GridExtensions.Masked(IGrid, ISet<Cell>)
GridExtensions.Masked(IGrid, Func<Cell, bool>, IEnumerable<Cell>)
GridExtensions.Move(IGrid, Cell, CellDir)
GridExtensions.ToMeshData(IGrid)
GridExtensions.ToMeshData(IGrid, IEnumerable<Cell>)
GridExtensions.Transformed(IGrid, Matrix4x4)
In this article
Back to top Generated by DocFX