Show / Hide Table of Contents

Class Path

Encapsulates a path as returned by pathfinding algorithms like AStar.

Inheritance
object
Path
Inherited Members
object.GetType()
object.MemberwiseClone()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
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 Source

Path(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 Source

End

Ending point of the path.

Declaration
public Point End { get; }
Property Value
Type Description
Point
View Source

Length

The length of the path, NOT including the starting point.

Declaration
public int Length { get; }
Property Value
Type Description
int
View Source

LengthWithStart

The length of the path, INCLUDING the starting point.

Declaration
public int LengthWithStart { get; }
Property Value
Type Description
int
View Source

Start

Starting point of the path.

Declaration
public Point Start { get; }
Property Value
Type Description
Point
View Source

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>
View Source

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 Source

GetStep(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.

View Source

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.

View Source

Reverse()

Reverses the path, in constant time.

Declaration
public void Reverse()
View Source

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.

Overrides
object.ToString()

Extension Methods

Utility.Yield<T>(T)
  • View Source
In this article
Back to top Generated by DocFX