Class PathFinder
A class which can be used to find shortest path from a source to a destination in a Map
Inheritance
Inherited Members
Namespace: RogueSharp
Assembly: RogueSharp.dll
Syntax
public class PathFinder
Constructors
| Improve this Doc View SourcePathFinder(IMap)
Constructs a new PathFinder instance for the specified Map that will not consider diagonal movements to be valid.
Declaration
public PathFinder(IMap map)
Parameters
Type | Name | Description |
---|---|---|
IMap | map | The Map that this PathFinder instance will run shortest path algorithms on |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when a null map parameter is passed in |
PathFinder(IMap, Double)
Constructs a new PathFinder instance for the specified Map that will consider diagonal movement by using the specified diagonalCost
Declaration
public PathFinder(IMap map, double diagonalCost)
Parameters
Type | Name | Description |
---|---|---|
IMap | map | The Map that this PathFinder instance will run shortest path algorithms on |
System.Double | diagonalCost | The cost of diagonal movement compared to horizontal or vertical movement. Use 1.0 if you want the same cost for all movements. On a standard cartesian map, it should be sqrt(2) (1.41) |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when a null map parameter is passed in |
Methods
| Improve this Doc View SourceShortestPath(ICell, ICell)
Returns a shortest Path containing a list of Cells from a specified source Cell to a destination Cell
Declaration
public Path ShortestPath(ICell source, ICell destination)
Parameters
Type | Name | Description |
---|---|---|
ICell | source | The Cell which is at the start of the path |
ICell | destination | The Cell which is at the end of the path |
Returns
Type | Description |
---|---|
Path | Returns a shortest Path containing a list of Cells from a specified source Cell to a destination Cell |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when source or destination is null |
PathNotFoundException | Thrown when there is not a path from the source to the destination |
TryFindShortestPath(ICell, ICell)
Returns a shortest Path containing a list of Cells from a specified source Cell to a destination Cell
Declaration
public Path TryFindShortestPath(ICell source, ICell destination)
Parameters
Type | Name | Description |
---|---|---|
ICell | source | The Cell which is at the start of the path |
ICell | destination | The Cell which is at the end of the path |
Returns
Type | Description |
---|---|
Path | Returns a shortest Path containing a list of Cells from a specified source Cell to a destination Cell. If no path is found null will be returned |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when source or destination is null |