Struct Direction
Represents a direction or neutral position
public struct Direction : IEquatable<Direction>
- Implements
Constructors
Direction(Vector2)
Creates a new direction from the given vector
public Direction(Vector2 direction)
Parameters
Fields
Down
public static readonly Direction Down
Field Value
Left
public static readonly Direction Left
Field Value
LeftDown
public static readonly Direction LeftDown
Field Value
LeftUp
public static readonly Direction LeftUp
Field Value
None
public static readonly Direction None
Field Value
Right
public static readonly Direction Right
Field Value
RightDown
public static readonly Direction RightDown
Field Value
RightUp
public static readonly Direction RightUp
Field Value
Up
public static readonly Direction Up
Field Value
Properties
IsNeutral
true
if the direction is in a neutral position. Same as checking against Direction.None
public bool IsNeutral { get; }
Property Value
Methods
Equals(Direction)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Direction other)
Parameters
other
DirectionAn object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
FromTicks(int, int)
Creates a new direction from a ratio. with 0/1 corresponding to the direction (0,1), 1/4 corresponding to (1,0), etc.
public static Direction FromTicks(int value, int maxValue)
Parameters
value
intThe amount of ticks clockwise from the Up direction (numerator)
maxValue
intThe number of ticks representing a full rotation (denominator)
Returns
- Direction
A direction with ratio
value
overmaxValue
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
GetTicks(int)
Retrieves the amount of ticks clockwise from the Up direction
public int GetTicks(int maxValue)
Parameters
maxValue
intThe number of ticks representing a full rotation
Returns
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()
Returns
- string
The fully qualified type name.
Operators
operator ==(Direction, Direction)
public static bool operator ==(Direction left, Direction right)
Parameters
Returns
explicit operator Direction(Vector2)
public static explicit operator Direction(Vector2 value)
Parameters
value
Vector2
Returns
explicit operator Vector2(Direction)
public static explicit operator Vector2(Direction value)
Parameters
value
Direction
Returns
operator !=(Direction, Direction)
public static bool operator !=(Direction left, Direction right)