Class Path
Encapsulates a path as returned by pathfinding algorithms like AStar.
Inheritance
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
| Improve this Doc View SourcePath(Path, Boolean)
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. |
System.Boolean | 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
| Improve this Doc View SourceEnd
Ending point of the path.
Declaration
public Coord End { get; }
Property Value
Type | Description |
---|---|
Coord |
Length
The length of the path, NOT including the starting point.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
LengthWithStart
The length of the path, INCLUDING the starting point.
Declaration
public int LengthWithStart { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Start
Starting point of the path.
Declaration
public Coord Start { get; }
Property Value
Type | Description |
---|---|
Coord |
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<Coord> Steps { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> |
StepsWithStart
The coordinates that constitute the path (in order), INCLUDING the starting point.
Declaration
public IEnumerable<Coord> StepsWithStart { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> |
Methods
| Improve this Doc View SourceGetStep(Int32)
Gets the nth step along the path, where 0 is the step AFTER the starting point.
Declaration
public Coord GetStep(int stepNum)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | stepNum | The (array-like index) of the step to get. |
Returns
Type | Description |
---|---|
Coord | The coordinate consituting the step specified. |
GetStepWithStart(Int32)
Gets the nth step along the path, where 0 IS the starting point.
Declaration
public Coord GetStepWithStart(int stepNum)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | stepNum | The (array-like index) of the step to get. |
Returns
Type | Description |
---|---|
Coord | The coordinate consituting 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 |
---|---|
System.String | A string representation of all steps in the path, including the start. |