diff --git a/Pal.Client/Marker.cs b/Pal.Client/Marker.cs index a212973..29f4932 100644 --- a/Pal.Client/Marker.cs +++ b/Pal.Client/Marker.cs @@ -1,4 +1,5 @@ using ECommons.SplatoonAPI; +using Pal.Common; using Palace; using System; using System.Collections.Generic; @@ -67,12 +68,12 @@ namespace Pal.Client public override int GetHashCode() { - return HashCode.Combine(Type, (int)Position.X, (int)Position.Y, (int)Position.Z); + return HashCode.Combine(Type, PalaceMath.GetHashCode(Position)); } public override bool Equals(object? obj) { - return obj is Marker otherMarker && Type == otherMarker.Type && (int)Position.X == (int)otherMarker.Position.X && (int)Position.Y == (int)otherMarker.Position.Y && (int)Position.Z == (int)otherMarker.Position.Z; + return obj is Marker otherMarker && Type == otherMarker.Type && PalaceMath.IsNearlySamePosition(Position, otherMarker.Position); } public static bool operator ==(Marker? a, object? b) diff --git a/Pal.Common/PalaceMath.cs b/Pal.Common/PalaceMath.cs new file mode 100644 index 0000000..2a7636e --- /dev/null +++ b/Pal.Common/PalaceMath.cs @@ -0,0 +1,17 @@ +using System.Numerics; + +namespace Pal.Common +{ + public class PalaceMath + { + public static bool IsNearlySamePosition(Vector3 a, Vector3 b) + { + return (int)a.X == (int)b.X && (int)a.Y == (int)b.Y && (int)a.Z == (int)b.Z; + } + + public static int GetHashCode(Vector3 v) + { + return HashCode.Combine((int)v.X, (int)v.Y, (int)v.Z); + } + } +}