diff --git a/HexCell.cs b/HexCell.cs index fd66124..626a58d 100644 --- a/HexCell.cs +++ b/HexCell.cs @@ -4,7 +4,7 @@ using System.Linq; using Godot; using Array = Godot.Collections.Array; -public class HexCell : Resource +public class HexCell : Resource, IEquatable { public static readonly Vector2 size = new Vector2(1, Mathf.Sqrt(3) / 2); public static readonly Vector3 DIR_N = new Vector3(0, 1, -1); @@ -26,14 +26,14 @@ public class HexCell : Resource CubeCoords = RoundCoords(new Vector3(cubeX, cubeY, cubeZ)); } - public static bool operator==(HexCell cellA, HexCell cellB) + public virtual bool Equals(HexCell other) { - return cellA.AxialCoords == cellB.AxialCoords; - } - - public static bool operator!=(HexCell cellA, HexCell cellB) - { - return cellA.AxialCoords != cellB.AxialCoords; + if (other == null) + { + return false; + } + + return CubeCoords == other.CubeCoords; } public HexCell(Vector3 cubeCoords)