Unity Grid Toolkit
Utilitary API to proceed operations on abstract grids such as tile extraction, raycasting, and pathfinding.
Loading...
Searching...
No Matches
Caskev.GridToolkit.DijkstraGrid Class Reference

A DijkstraGrid object holds both direction and distance data between a target tile and all the tiles that are accessible to this target, on the entire grid. More...

Public Member Functions

bool IsTileAccessible< T > (T[,] grid, T tile)
 Is the tile is accessible from the target.
 
GetTargetTile< T > (T[,] grid)
 Returns the target tile.
 
GetNextTile< T > (T[,] grid, T tile)
 Get the next tile on the path between a tile and the target.
 
TileDirection GetNextDirection< T > (T[,] grid, T tile)
 Get the next tile on the path between the target and a tile.
 
float GetDistanceToTarget< T > (T[,] grid, T tile)
 Get the distance from the specified tile to the target.
 
T[] GetPathToTarget< T > (T[,] grid, T startTile, bool includeStart=true, bool includeTarget=true)
 Get all the tiles on the path from a tile to the target.
 
T[] GetPathFromTarget< T > (T[,] grid, T destinationTile, bool includeDestination=true, bool includeTarget=true)
 Get all the tiles on the path from the target to a tile.
 
byte[] ToByteArray ()
 Returns the DijkstraGrid serialized as a byte array.
 
Task< byte[]> ToByteArrayAsync (IProgress< float > progress=null, CancellationToken cancelToken=default)
 Returns the DijkstraGrid serialized as a byte array.
 
async Awaitable< byte[]> ToByteArrayAwaitable (IProgress< float > progress=null, CancellationToken cancelToken=default)
 Returns the DijkstraGrid serialized as a byte array.
 

Static Public Member Functions

static DijkstraGrid FromByteArray< T > (T[,] grid, byte[] bytes)
 Returns a DijkstraGrid from a byte array that has been serialized with the ToByteArray method.
 
static Task< DijkstraGridFromByteArrayAsync< T > (T[,] grid, byte[] bytes, IProgress< float > progress=null, CancellationToken cancelToken=default)
 Returns a DijkstraGrid from a byte array that has been serialized with the ToByteArray method.
 
static async Awaitable< DijkstraGridFromByteArrayAwaitable< T > (T[,] grid, byte[] bytes, IProgress< float > progress=null, CancellationToken cancelToken=default)
 Returns a DijkstraGrid from a byte array that has been serialized with the ToByteArray method.
 

Detailed Description

A DijkstraGrid object holds both direction and distance data between a target tile and all the tiles that are accessible to this target, on the entire grid.

Member Function Documentation

◆ FromByteArray< T >()

static DijkstraGrid Caskev.GridToolkit.DijkstraGrid.FromByteArray< T > ( grid[,],
byte[]  bytes 
)
static

Returns a DijkstraGrid from a byte array that has been serialized with the ToByteArray method.

Parameters
gridThe user grid
bytesThe serialized byte array
Returns
The deserialized DijkstraGrid
Type Constraints
T :IWeightedTile 

◆ FromByteArrayAsync< T >()

static Task< DijkstraGrid > Caskev.GridToolkit.DijkstraGrid.FromByteArrayAsync< T > ( grid[,],
byte[]  bytes,
IProgress< float >  progress = null,
CancellationToken  cancelToken = default 
)
static

Returns a DijkstraGrid from a byte array that has been serialized with the ToByteArray method.

Parameters
gridThe user grid
bytesThe serialized byte array
progressAn optional IProgress object to get the deserialization progression
cancelTokenAn optional CancellationToken object to cancel the deserialization
Returns
The deserialized DijkstraGrid
Type Constraints
T :IWeightedTile 

◆ FromByteArrayAwaitable< T >()

static async Awaitable< DijkstraGrid > Caskev.GridToolkit.DijkstraGrid.FromByteArrayAwaitable< T > ( grid[,],
byte[]  bytes,
IProgress< float >  progress = null,
CancellationToken  cancelToken = default 
)
static

Returns a DijkstraGrid from a byte array that has been serialized with the ToByteArray method.

Parameters
gridThe user grid
bytesThe serialized byte array
progressAn optional IProgress object to get the deserialization progression
cancelTokenAn optional CancellationToken object to cancel the deserialization
Returns
The deserialized DijkstraGrid
Type Constraints
T :IWeightedTile 

◆ GetDistanceToTarget< T >()

float Caskev.GridToolkit.DijkstraGrid.GetDistanceToTarget< T > ( grid[,],
tile 
)

Get the distance from the specified tile to the target.

Parameters
gridA two-dimensional array of tiles
tileThe tile from which to get the distance to the target tile
Returns
The float distance from the specified tile to the target tile
Type Constraints
T :IWeightedTile 

◆ GetNextDirection< T >()

TileDirection Caskev.GridToolkit.DijkstraGrid.GetNextDirection< T > ( grid[,],
tile 
)

Get the next tile on the path between the target and a tile.

Parameters
gridA two-dimensional array of tiles
tileThe tile
Returns
A Vector2Int direction
Type Constraints
T :IWeightedTile 

◆ GetNextTile< T >()

T Caskev.GridToolkit.DijkstraGrid.GetNextTile< T > ( grid[,],
tile 
)

Get the next tile on the path between a tile and the target.

Parameters
gridA two-dimensional array of tiles
tileA tile
Returns
A tile object
Type Constraints
T :IWeightedTile 

◆ GetPathFromTarget< T >()

T[] Caskev.GridToolkit.DijkstraGrid.GetPathFromTarget< T > ( grid[,],
destinationTile,
bool  includeDestination = true,
bool  includeTarget = true 
)

Get all the tiles on the path from the target to a tile.

Parameters
gridA two-dimensional array of tiles
destinationTileThe destination tile
includeDestinationInclude the destination tile into the resulting array or not. Default is true
includeTargetInclude the target tile into the resulting array or not
Returns
An array of tiles
Type Constraints
T :IWeightedTile 

◆ GetPathToTarget< T >()

T[] Caskev.GridToolkit.DijkstraGrid.GetPathToTarget< T > ( grid[,],
startTile,
bool  includeStart = true,
bool  includeTarget = true 
)

Get all the tiles on the path from a tile to the target.

Parameters
gridA two-dimensional array of tiles
startTileThe start tile
includeStartInclude the start tile into the resulting array or not. Default is true
includeTargetInclude the target tile into the resulting array or not
Returns
An array of tiles
Type Constraints
T :IWeightedTile 

◆ GetTargetTile< T >()

T Caskev.GridToolkit.DijkstraGrid.GetTargetTile< T > ( grid[,])

Returns the target tile.

Parameters
gridA two-dimensional array of tiles
Returns
Type Constraints
T :IWeightedTile 

◆ IsTileAccessible< T >()

bool Caskev.GridToolkit.DijkstraGrid.IsTileAccessible< T > ( grid[,],
tile 
)

Is the tile is accessible from the target.

Parameters
gridA two-dimensional array of tiles
tileThe tile to check
Returns
A boolean value
Type Constraints
T :IWeightedTile 

◆ ToByteArray()

byte[] Caskev.GridToolkit.DijkstraGrid.ToByteArray ( )

Returns the DijkstraGrid serialized as a byte array.

Returns
A byte array representing the serialized DijkstraGrid

◆ ToByteArrayAsync()

Task< byte[]> Caskev.GridToolkit.DijkstraGrid.ToByteArrayAsync ( IProgress< float >  progress = null,
CancellationToken  cancelToken = default 
)

Returns the DijkstraGrid serialized as a byte array.

Parameters
progressAn optional IProgress object to get the serialization progression
cancelTokenAn optional CancellationToken object to cancel the serialization
Returns
A byte array representing the serialized DijkstraGrid

◆ ToByteArrayAwaitable()

async Awaitable< byte[]> Caskev.GridToolkit.DijkstraGrid.ToByteArrayAwaitable ( IProgress< float >  progress = null,
CancellationToken  cancelToken = default 
)

Returns the DijkstraGrid serialized as a byte array.

Parameters
progressAn optional IProgress object to get the serialization progression
cancelTokenAn optional CancellationToken object to cancel the serialization
Returns
A byte array representing the serialized DijkstraGrid

The documentation for this class was generated from the following file: