Class Path
Encapsulates a path as returned by pathfinding algorithms like AStar.
Inherited Members
Namespace: GoRogue.Pathing
Assembly: GoRogue.dll
Syntax
public class Path
Remarks
Provides various functions to iterate through/access steps of the path, as well as constant-time reversing functionality.
Constructors
View SourcePath(Path, bool)
Creates a copy of the path, optionally reversing the path as it does so.
Declaration
public Path(Path pathToCopy, bool reverse = false)
Parameters
Type | Name | Description |
---|---|---|
Path | pathToCopy | The path to copy. |
bool | reverse | Whether or not to reverse the path. Defaults to false. |
Remarks
Reversing is an O(1) operation, since it does not modify the list.
Properties
View SourceEnd
Ending point of the path.
Declaration
public Point End { get; }
Property Value
Type | Description |
---|---|
Point |
Length
The length of the path, NOT including the starting point.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
int |
LengthWithStart
The length of the path, INCLUDING the starting point.
Declaration
public int LengthWithStart { get; }
Property Value
Type | Description |
---|---|
int |
Start
Starting point of the path.
Declaration
public Point Start { get; }
Property Value
Type | Description |
---|---|
Point |
Steps
The coordinates that constitute the path (in order), NOT including the starting point. These are the coordinates something might walk along to follow a path.
Declaration
public IEnumerable<Point> Steps { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Point> |
StepsWithStart
The coordinates that constitute the path (in order), INCLUDING the starting point.
Declaration
public IEnumerable<Point> StepsWithStart { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Point> |
Methods
View SourceGetStep(int)
Gets the nth step along the path, where 0 is the step AFTER the starting point.
Declaration
public Point GetStep(int stepNum)
Parameters
Type | Name | Description |
---|---|---|
int | stepNum | The (array-like index) of the step to get. |
Returns
Type | Description |
---|---|
Point | The coordinate constituting the step specified. |
GetStepWithStart(int)
Gets the nth step along the path, where 0 IS the starting point.
Declaration
public Point GetStepWithStart(int stepNum)
Parameters
Type | Name | Description |
---|---|---|
int | stepNum | The (array-like index) of the step to get. |
Returns
Type | Description |
---|---|
Point | The coordinate constituting the step specified. |
Reverse()
Reverses the path, in constant time.
Declaration
public void Reverse()
ToString()
Returns a string representation of all the steps in the path, including the start point, eg. [(1, 2), (3, 4), (5, 6)].
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string representation of all steps in the path, including the start. |