Struct CardinalDirection
Represents a north/east/south/west direction. North is the positive z axis. East is positive x axis.
Namespace: TycoonTerrain.Core
Assembly: TycoonTerrainAssembly.dll
Syntax
public struct CardinalDirection : IEquatable<CardinalDirection>
Constructors
CardinalDirection(int2)
Returns a direction from an offset vector.
Declaration
public CardinalDirection(int2 vector)
Parameters
| Type | Name | Description |
|---|---|---|
| Unity. |
vector | The offset vector. |
Properties
All
Enumerates every direction in the order north, east, south, west.
Declaration
public static IEnumerable<CardinalDirection> All { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<Cardinal |
Every direction in the order north, east, south, west. |
East
Gets the east direction.
Declaration
public static CardinalDirection East { get; }
Property Value
| Type | Description |
|---|---|
| Cardinal |
The east direction. |
Inverse
Returns the opposite direction.
Declaration
public CardinalDirection Inverse { get; }
Property Value
| Type | Description |
|---|---|
| Cardinal |
The opposite direction fo the current direction. |
Examples
North.Inverse returns South.
North
Gets the north direction.
Declaration
public static CardinalDirection North { get; }
Property Value
| Type | Description |
|---|---|
| Cardinal |
The north direction. |
RotateLeft
Returns the direction when one would turn 90 degrees to the left from the current direction.
Declaration
public CardinalDirection RotateLeft { get; }
Property Value
| Type | Description |
|---|---|
| Cardinal |
The direction when one would turn 90 degrees to the left from the current direction. |
Examples
North.RotateLeft returns West.
RotateRight
Returns the direction when one would turn 90 degrees to the right from the current direction.
Declaration
public CardinalDirection RotateRight { get; }
Property Value
| Type | Description |
|---|---|
| Cardinal |
The direction when one would turn 90 degrees to the right from the current direction. |
Examples
North.RotateRight returns East.
South
Gets the south direction.
Declaration
public static CardinalDirection South { get; }
Property Value
| Type | Description |
|---|---|
| Cardinal |
The south direction. |
West
Gets the west direction.
Declaration
public static CardinalDirection West { get; }
Property Value
| Type | Description |
|---|---|
| Cardinal |
The west direction. |
Methods
Equals(Object)
Determines whether the specified Object, is equal to this instance.
Declaration
public override bool Equals(object obj)
Parameters
Returns
Overrides
Equals(CardinalDirection)
Equalses the specified other.
Declaration
public bool Equals(CardinalDirection other)
Parameters
| Type | Name | Description |
|---|---|---|
| Cardinal |
other | The other. |
Returns
| Type | Description |
|---|---|
| Boolean |
GetDirectionFromCorner(CornerIndex, Boolean)
Returns a direction from the point of view of a corner index, facing outwards.
Declaration
public static CardinalDirection GetDirectionFromCorner(CornerIndex corner, bool left)
Parameters
| Type | Name | Description |
|---|---|---|
| Corner |
corner | The corner index. |
| Boolean | left | Whether to return the left or right direction. |
Returns
| Type | Description |
|---|---|
| Cardinal |
Examples
GetDirectionFromCorner(CornerIndex.NorthEast, true) returns North.
GetDirectionFromCorner(CornerIndex.NorthEast, false) returns East.
GetHashCode()
Returns a hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
ToString()
Converts to string.
Declaration
public override string ToString()
Returns
Overrides
ToVector()
Returns the offset in tile positions that is represented by the direction.
Declaration
public int2 ToVector()
Returns
| Type | Description |
|---|---|
| Unity. |
Operators
Equality(CardinalDirection, CardinalDirection)
Implements the operator ==.
Declaration
public static bool operator ==(CardinalDirection left, CardinalDirection right)
Parameters
| Type | Name | Description |
|---|---|---|
| Cardinal |
left | The left. |
| Cardinal |
right | The right. |
Returns
| Type | Description |
|---|---|
| Boolean | The result of the operator. |
Inequality(CardinalDirection, CardinalDirection)
Implements the operator !=.
Declaration
public static bool operator !=(CardinalDirection left, CardinalDirection right)
Parameters
| Type | Name | Description |
|---|---|---|
| Cardinal |
left | The left. |
| Cardinal |
right | The right. |
Returns
| Type | Description |
|---|---|
| Boolean | The result of the operator. |