Skip to content

Commit 20ddd2c

Browse files
committed
Cardinal and Flags work
1 parent 8915004 commit 20ddd2c

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

Framework/Spatial/Cardinal.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public Cardinal(int val)
3636
public bool Horizontal => Value % 2 == 0;
3737
public bool Vertical => Value % 2 == 1;
3838
public Point2 Point => new(X, Y);
39+
public Vector2 Normal => new(X, Y);
3940

4041
public int X => Value switch
4142
{
@@ -63,6 +64,7 @@ public Cardinal(int val)
6364
_ => throw new Exception()
6465
};
6566

67+
public static implicit operator Cardinal(int val) => new(val);
6668
public static implicit operator Cardinal(Facing f) => f.Sign > 0 ? Right : Left;
6769
public static implicit operator Point2(Cardinal c) => c.Point;
6870
public static bool operator ==(Cardinal a, Cardinal b) => a.Value == b.Value;

Framework/Utility/Calc.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@ public static bool HasAllFlags(this uint flags, uint check)
9090
public static bool HasAnyFlags(this uint flags, uint check)
9191
=> (flags & check) != 0;
9292

93+
public static bool HasAllFlags(this ulong flags, ulong check)
94+
=> (flags & check) == check;
95+
96+
public static bool HasAnyFlags(this ulong flags, ulong check)
97+
=> (flags & check) != 0;
98+
9399
public static float Avg(float a, float b)
94100
=> a + (b - a) * .5f;
95101

0 commit comments

Comments
 (0)