Better equality operator for HexCell.

WorldChunkRefactoring
Martin Felis 2023-08-12 14:27:30 +02:00
parent 5b6efaebe9
commit 10afa67d85
1 changed files with 8 additions and 8 deletions

View File

@ -4,7 +4,7 @@ using System.Linq;
using Godot;
using Array = Godot.Collections.Array;
public class HexCell : Resource
public class HexCell : Resource, IEquatable<HexCell>
{
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;
}
if (other == null)
{
return false;
}
public static bool operator!=(HexCell cellA, HexCell cellB)
{
return cellA.AxialCoords != cellB.AxialCoords;
return CubeCoords == other.CubeCoords;
}
public HexCell(Vector3 cubeCoords)