Class AdjacencyRule
Class representing a method for determining which coordinates are adjacent to a given coordinate, and which directions those neighbors are in. Cannot be instantiated -- premade static instances are provided.
Inheritance
Implements
Inherited Members
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
[Serializable]
public class AdjacencyRule : IEquatable<AdjacencyRule>
Fields
| Improve this Doc View SourceCARDINALS
Represents method of determining adjacency where neighbors are considered adjacent if they are in a cardinal direction, eg. 4-way (manhattan-based) connectivity.
Declaration
[NonSerialized]
public static readonly AdjacencyRule CARDINALS
Field Value
Type | Description |
---|---|
AdjacencyRule |
DIAGONALS
Represents method of determining adjacency where neighbors are considered adjacent only if they are in a diagonal direction.
Declaration
[NonSerialized]
public static readonly AdjacencyRule DIAGONALS
Field Value
Type | Description |
---|---|
AdjacencyRule |
EIGHT_WAY
Represents method of determining adjacency where all 8 possible neighbors are considered adjacent (eg. 8-way connectivity).
Declaration
[NonSerialized]
public static readonly AdjacencyRule EIGHT_WAY
Field Value
Type | Description |
---|---|
AdjacencyRule |
Type
Enum value representing the method of determining adjacency -- useful for using AdjacencyRule types in switch statements.
Declaration
public readonly AdjacencyRule.Types Type
Field Value
Type | Description |
---|---|
AdjacencyRule.Types |
Methods
| Improve this Doc View SourceDirectionsOfNeighbors()
Gets directions leading to neighboring locations, according to the current adjacency method. Cardinals are returned before any diagonals.
Declaration
public IEnumerable<Direction> DirectionsOfNeighbors()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Direction> | Directions that lead to neighboring locations. |
DirectionsOfNeighborsClockwise(Direction)
Gets directions leading to neighboring locations, according to the current adjacency method. Appropriate directions are returned in clockwise order from the given starting direction.
Declaration
public IEnumerable<Direction> DirectionsOfNeighborsClockwise(Direction startingDirection = null)
Parameters
Type | Name | Description |
---|---|---|
Direction | startingDirection | The direction to start with. null or NONE causes the default starting direction to be used, which is UP for CARDINALS/EIGHT_WAY, and UP_RIGHT for diagonals. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Direction> | Directions that lead to neighboring locations. |
DirectionsOfNeighborsCounterClockwise(Direction)
Gets directions leading to neighboring locations, according to the current adjacency method. Appropriate directions are returned in counter-clockwise order from the given starting direction.
Declaration
public IEnumerable<Direction> DirectionsOfNeighborsCounterClockwise(Direction startingDirection = null)
Parameters
Type | Name | Description |
---|---|---|
Direction | startingDirection | The direction to start with. null or NONE causes the default starting direction to be used, which is UP for CARDINALS/EIGHT_WAY, and UP_LEFT for diagonals. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Direction> | Directions that lead to neighboring locations. |
Equals(AdjacencyRule)
Compares the current AdjacencyRule to the one given.
Declaration
public bool Equals(AdjacencyRule other)
Parameters
Type | Name | Description |
---|---|---|
AdjacencyRule | other |
Returns
Type | Description |
---|---|
System.Boolean | True if the given AdjacencyRule has the same Type, false otherwise. |
Equals(Object)
Compares the current AdjacencyRule to the object given.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj |
Returns
Type | Description |
---|---|
System.Boolean | True if the given object is an AdjacencyRule with the same Type, false otherwise. |
Overrides
GetHashCode()
Returns a hash-value for this object.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 |
Overrides
Neighbors(Coord)
Gets all neighbors of the specified location, based on the current adjacency method. Cardinals are returned before any diagonals.
Declaration
public IEnumerable<Coord> Neighbors(Coord startingLocation)
Parameters
Type | Name | Description |
---|---|---|
Coord | startingLocation | Location to return neighbors for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> | All neighbors of the given location. |
Neighbors(Int32, Int32)
Gets all neighbors of the specified location, based on the current adjacency method. Cardinals are returned before any diagonals.
Declaration
public IEnumerable<Coord> Neighbors(int startingX, int startingY)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startingX | X-coordinate of location to return neighbors for. |
System.Int32 | startingY | Y-coordinate of location to return neighbors for. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> | All neighbors of the given location. |
NeighborsClockwise(Coord, Direction)
Gets all neighbors of the specified location, based on the current adjacency method. Neighbors are returned in clockwise order, starting with the neighbor in the given starting direction.
Declaration
public IEnumerable<Coord> NeighborsClockwise(Coord startingLocation, Direction startingDirection = null)
Parameters
Type | Name | Description |
---|---|---|
Coord | startingLocation | Location to return neighbors for. |
Direction | startingDirection | The neighbor in this direction will be returned first, proceeding clockwise. If null or NONE is specified, the default starting direction is used, which is UP for CARDINALS/EIGHT_WAY, and UP_RIGHT for DIAGONALS. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> | All neighbors of the given location. |
NeighborsClockwise(Int32, Int32, Direction)
Gets all neighbors of the specified location, based on the current adjacency method. Neighbors are returned in clockwise order, starting with the neighbor in the given starting direction.
Declaration
public IEnumerable<Coord> NeighborsClockwise(int startingX, int startingY, Direction startingDirection = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startingX | X-coordinate of location to return neighbors for. |
System.Int32 | startingY | Y-coordinate of location to return neighbors for. |
Direction | startingDirection | The neighbor in this direction will be returned first, proceeding clockwise. If null or NONE is specified, the default starting direction is used, which is UP for CARDINALS/EIGHT_WAY, and UP_RIGHT for DIAGONALS. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> | All neighbors of the given location. |
NeighborsCounterClockwise(Coord, Direction)
Gets all neighbors of the specified location, based on the current adjacency method. Neighbors are returned in counter-clockwise order, starting with the neighbor in the given starting direction.
Declaration
public IEnumerable<Coord> NeighborsCounterClockwise(Coord startingLocation, Direction startingDirection = null)
Parameters
Type | Name | Description |
---|---|---|
Coord | startingLocation | Location to return neighbors for. |
Direction | startingDirection | The neighbor in this direction will be returned first, proceeding counter-clockwise. If null or NONE is specified, the default starting direction is used, which is UP for CARDINALS/EIGHT_WAY, and UP_LEFT for DIAGONALS. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> | All neighbors of the given location. |
NeighborsCounterClockwise(Int32, Int32, Direction)
Gets all neighbors of the specified location, based on the current adjacency method. Neighbors are returned in counter-clockwise order, starting with the neighbor in the given starting direction.
Declaration
public IEnumerable<Coord> NeighborsCounterClockwise(int startingX, int startingY, Direction startingDirection = null)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | startingX | X-coordinate of location to return neighbors for. |
System.Int32 | startingY | Y-coordinate of location to return neighbors for. |
Direction | startingDirection | The neighbor in this direction will be returned first, proceeding counter-clockwise. If null or NONE is specified, the default starting direction is used, which is UP for CARDINALS/EIGHT_WAY, and UP_LEFT for DIAGONALS. |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<Coord> | All neighbors of the given location. |
ToAdjacencyRule(AdjacencyRule.Types)
Gets the AdjacencyRule class instance representing the adjacency type specified.
Declaration
public static AdjacencyRule ToAdjacencyRule(AdjacencyRule.Types adjacencyRuleType)
Parameters
Type | Name | Description |
---|---|---|
AdjacencyRule.Types | adjacencyRuleType | The enum value for the adjacency method. |
Returns
Type | Description |
---|---|
AdjacencyRule | The AdjacencyRule class representing the given adjacency method type. |
ToString()
Returns a string representation of the AdjacencyRule.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A string representation of the AdjacencyRule. |
Overrides
Operators
| Improve this Doc View SourceEquality(AdjacencyRule, AdjacencyRule)
Compares the two AdjacencyRule instances.
Declaration
public static bool operator ==(AdjacencyRule lhs, AdjacencyRule rhs)
Parameters
Type | Name | Description |
---|---|---|
AdjacencyRule | lhs | |
AdjacencyRule | rhs |
Returns
Type | Description |
---|---|
System.Boolean | True if the two given AdjacencyRule instances have the same Type, false otherwise. |
Inequality(AdjacencyRule, AdjacencyRule)
Compares the two AdjacencyRule instances.
Declaration
public static bool operator !=(AdjacencyRule lhs, AdjacencyRule rhs)
Parameters
Type | Name | Description |
---|---|---|
AdjacencyRule | lhs | |
AdjacencyRule | rhs |
Returns
Type | Description |
---|---|
System.Boolean | True if the two given AdjacencyRule instances do NOT have the same Type, false otherwise. |