Move duplication logic for positions into commons
This commit is contained in:
parent
53bd00285b
commit
136774eb71
@ -1,4 +1,5 @@
|
|||||||
using ECommons.SplatoonAPI;
|
using ECommons.SplatoonAPI;
|
||||||
|
using Pal.Common;
|
||||||
using Palace;
|
using Palace;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@ -67,12 +68,12 @@ namespace Pal.Client
|
|||||||
|
|
||||||
public override int GetHashCode()
|
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)
|
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)
|
public static bool operator ==(Marker? a, object? b)
|
||||||
|
17
Pal.Common/PalaceMath.cs
Normal file
17
Pal.Common/PalaceMath.cs
Normal file
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user