mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-23 05:08:34 +01:00
Turned Direction2 into a flags enum
This commit is contained in:
parent
dda827b985
commit
468bee9ca8
1 changed files with 39 additions and 37 deletions
|
@ -7,47 +7,49 @@ namespace MLEM.Misc {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An enum that represents two-dimensional directions.
|
/// An enum that represents two-dimensional directions.
|
||||||
/// Both straight and diagonal directions are supported.
|
/// Both straight and diagonal directions are supported.
|
||||||
|
/// There are several extension methods and arrays available in <see cref="Direction2Helper"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
public enum Direction2 {
|
public enum Direction2 {
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The up direction, or -y.
|
|
||||||
/// </summary>
|
|
||||||
Up,
|
|
||||||
/// <summary>
|
|
||||||
/// The right direction, or +x.
|
|
||||||
/// </summary>
|
|
||||||
Right,
|
|
||||||
/// <summary>
|
|
||||||
/// The down direction, or +y.
|
|
||||||
/// </summary>
|
|
||||||
Down,
|
|
||||||
/// <summary>
|
|
||||||
/// The left direction, or -x.
|
|
||||||
/// </summary>
|
|
||||||
Left,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The up and right direction, or +x, -y.
|
|
||||||
/// </summary>
|
|
||||||
UpRight,
|
|
||||||
/// <summary>
|
|
||||||
/// The down and right direction, or +x, +y.
|
|
||||||
/// </summary>
|
|
||||||
DownRight,
|
|
||||||
/// <summary>
|
|
||||||
/// The down and left direction, or -x, +y.
|
|
||||||
/// </summary>
|
|
||||||
DownLeft,
|
|
||||||
/// <summary>
|
|
||||||
/// The up and left direction, or -x, -y.
|
|
||||||
/// </summary>
|
|
||||||
UpLeft,
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// No direction.
|
/// No direction.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
None
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The up direction, or -y.
|
||||||
|
/// </summary>
|
||||||
|
Up = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// The right direction, or +x.
|
||||||
|
/// </summary>
|
||||||
|
Right = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// The down direction, or +y.
|
||||||
|
/// </summary>
|
||||||
|
Down = 4,
|
||||||
|
/// <summary>
|
||||||
|
/// The left direction, or -x.
|
||||||
|
/// </summary>
|
||||||
|
Left = 8,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The up and right direction, or +x, -y.
|
||||||
|
/// </summary>
|
||||||
|
UpRight = Up | Right,
|
||||||
|
/// <summary>
|
||||||
|
/// The down and right direction, or +x, +y.
|
||||||
|
/// </summary>
|
||||||
|
DownRight = Down | Right,
|
||||||
|
/// <summary>
|
||||||
|
/// The up and left direction, or -x, -y.
|
||||||
|
/// </summary>
|
||||||
|
UpLeft = Up | Left,
|
||||||
|
/// <summary>
|
||||||
|
/// The down and left direction, or -x, +y.
|
||||||
|
/// </summary>
|
||||||
|
DownLeft = Down | Left
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +82,7 @@ namespace MLEM.Misc {
|
||||||
/// <param name="dir">The direction to query</param>
|
/// <param name="dir">The direction to query</param>
|
||||||
/// <returns>Whether the direction is adjacent</returns>
|
/// <returns>Whether the direction is adjacent</returns>
|
||||||
public static bool IsAdjacent(this Direction2 dir) {
|
public static bool IsAdjacent(this Direction2 dir) {
|
||||||
return dir <= Direction2.Left;
|
return dir == Direction2.Up || dir == Direction2.Right || dir == Direction2.Down || dir == Direction2.Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -89,7 +91,7 @@ namespace MLEM.Misc {
|
||||||
/// <param name="dir">The direction to query</param>
|
/// <param name="dir">The direction to query</param>
|
||||||
/// <returns>Whether the direction is diagonal</returns>
|
/// <returns>Whether the direction is diagonal</returns>
|
||||||
public static bool IsDiagonal(this Direction2 dir) {
|
public static bool IsDiagonal(this Direction2 dir) {
|
||||||
return dir >= Direction2.UpRight && dir <= Direction2.UpLeft;
|
return dir == Direction2.UpRight || dir == Direction2.DownRight || dir == Direction2.UpLeft || dir == Direction2.DownLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue