Skip to content

Commit

Permalink
Workaround for buggy autogenerated GetHashCode for records...
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed May 12, 2024
1 parent c397864 commit 15461a9
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BossMod/Util/WPosDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public WDir(Vector2 v) : this(v.X, v.Y) { }
public readonly bool AlmostEqual(WDir b, float eps) => AlmostZero(this - b, eps);

public override readonly string ToString() => $"({X:f3}, {Z:f3})";
public override readonly int GetHashCode() => (X, Z).GetHashCode(); // TODO: this is a hack, the default should be good enough, but for whatever reason (X, -Z).GetHashCode() == (-X, Z).GetHashCode()...

// area checks, assuming this is an offset from shape's center
public readonly bool InRect(WDir direction, float lenFront, float lenBack, float halfWidth)
Expand Down Expand Up @@ -64,6 +65,7 @@ public WPos(Vector2 v) : this(v.X, v.Y) { }
public static WPos Lerp(WPos from, WPos to, float progress) => new(from.ToVec2() * (1 - progress) + to.ToVec2() * progress);

public override readonly string ToString() => $"[{X:f3}, {Z:f3}]";
public override readonly int GetHashCode() => (X, Z).GetHashCode(); // TODO: this is a hack, the default should be good enough, but for whatever reason (X, -Z).GetHashCode() == (-X, Z).GetHashCode()...

// area checks
public readonly bool InTri(WPos v1, WPos v2, WPos v3)
Expand Down

0 comments on commit 15461a9

Please sign in to comment.