Class MovingGrid<T>
A data structure that provides a two-dimensional local grid of cells with reference to a global position. The grid position is intended to move and therefore free all cells that don't overlap with the target area.
Namespace: Holoride.ElasticSDK
Assembly: Holoride.ElasticSDK.Library.Runtime.dll
Syntax
public class MovingGrid<T>
Type Parameters
Name | Description |
---|---|
T |
Constructors
MovingGrid(int)
Creates the empty data structure.
Declaration
public MovingGrid(int gridRadius)
Parameters
Type | Name | Description |
---|---|---|
int | gridRadius | The distance from the center of the square grid area to any one of its four edges. This intentionally results in an uneven square extent. |
Properties
GridCenterPosition
Gets the current grid center position within the global support range.
Declaration
public Vector2Int GridCenterPosition { get; }
Property Value
Type | Description |
---|---|
Vector2Int |
this[int, int]
Provides access to a grid cell by addressing the global 2d-position. Will return default value or null if outside the grid.
Declaration
public T this[int x, int y] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | x | |
int | y |
Property Value
Type | Description |
---|---|
T |
this[Vector2Int]
Provides access to a grid cell by addressing the global 2d-position.
Declaration
public T this[Vector2Int position] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | position |
Property Value
Type | Description |
---|---|
T |
Methods
Clear(Action<T>)
Clears the contents of this grid, resetting every cell to its default value.
Declaration
public void Clear(Action<T> forEachCell = null)
Parameters
Type | Name | Description |
---|---|---|
Action<T> | forEachCell | A callback invoked for each non-default cell to allow extra disposal steps that may be needed for the contents of this grid. |
Move(Vector2Int, Func<Vector2Int, T, CancellationToken, UniTask>, CancellationToken)
Moves the grid.
Declaration
public UniTask Move(Vector2Int targetCenterPosition, Func<Vector2Int, T, CancellationToken, UniTask> forAllCellsToOverwrite = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | targetCenterPosition | The target position where to move the center of the grid to. |
Func<Vector2Int, T, CancellationToken, Cysharp.Threading.Tasks.UniTask> | forAllCellsToOverwrite | The callback on every cell that gets overridden. The parameters are the new global cell position and the dropped cell value. |
CancellationToken | cancellationToken | The token to monitor for cancellation requests. |
Returns
Type | Description |
---|---|
Cysharp.Threading.Tasks.UniTask |
Supports(int, int)
States whether the current grid supports the given position.
Declaration
public bool Supports(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
int | x | The x coordinate. |
int | y | The y coordinate. |
Returns
Type | Description |
---|---|
bool | Whether the position is in bounds. |
Supports(Vector2Int)
States whether the current grid supports the given position.
Declaration
public bool Supports(Vector2Int position)
Parameters
Type | Name | Description |
---|---|---|
Vector2Int | position | The position. |
Returns
Type | Description |
---|---|
bool | Whether the position is in bounds. |