DirectionExtensions

Static class in ChivalrousGames.Common

Description

Provides a variety of helper methods to the Direction enumeration.

Static Methods

GetOppositeDirection
public static Direction GetOppositeDirection(this Direction direction);
Return
Direction A new instance of Direction
Description

This methods return the direction logically opposite to the current one.

Rotate
public static Direction Rotate(this Direction direction, PointRotation rotation);
Parameters
rotation PointRotation The rotation to apply to the direction
Return
Direction A new instance of Direction
Description

Rotates a direction clockwise when looking toward the negative values of the axis (like Unity does in the inspector).

Usage Example
Direction rotatedDirection = Direction.Up.Rotate (new PointRotation(0,	0,	90));
//In this example, the Up direction is rotated 90 degrees clockwise around the Z axis when looking toward negative Z values, which will result in a Left direction.
ReverseRotate
public static Direction ReverseRotate(this Direction direction, PointRotation rotation);
Parameters
rotation PointRotation The rotation to apply to the direction
Return
Direction A new instance of Direction
Description

Rotates a direction counter-clockwise when looking toward the negative values of the axis (the opposite of what Unity does in the inspector).

Usage Example
Direction rotatedDirection = Direction.Up.ReverseRotate (new PointRotation(0,	0,	90));
//In this example, the Up direction is rotated 90 degrees counter-clockwise around the Z axis when looking toward negative Z values, which will result in a Right direction.
Rotate90AroundX
public static Direction Rotate90AroundX(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 90 degrees clockwise around the X axis when looking toward the negative values of the axis.

Rotate180AroundX
public static Direction Rotate180AroundX(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 180 degrees clockwise around the X axis when looking toward the negative values of the axis.

Rotate270AroundX
public static Direction Rotate270AroundX(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 270 degrees clockwise around the X axis when looking toward the negative values of the axis.

Rotate90AroundY
public static Direction Rotate90AroundY(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 90 degrees clockwise around the Y axis when looking toward the negative values of the axis.

Rotate180AroundY
public static Direction Rotate180AroundY(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 180 degrees clockwise around the Y axis when looking toward the negative values of the axis.

Rotate270AroundY
public static Direction Rotate270AroundY(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 270 degrees clockwise around the Y axis when looking toward the negative values of the axis.

Rotate90AroundZ
public static Direction Rotate90AroundZ(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 90 degrees clockwise around the Z axis when looking toward the negative values of the axis.

Rotate180AroundZ
public static Direction Rotate180AroundZ(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 180 degrees clockwise around the Z axis when looking toward the negative values of the axis.

Rotate270AroundZ
public static Direction Rotate270AroundZ(this Direction direction);
Return
Direction A new instance of Direction
Description

Rotates a direction 270 degrees clockwise around the Z axis when looking toward the negative values of the axis.