Better equality operator for HexCell.
parent
5b6efaebe9
commit
10afa67d85
16
HexCell.cs
16
HexCell.cs
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||||
using Godot;
|
using Godot;
|
||||||
using Array = Godot.Collections.Array;
|
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 Vector2 size = new Vector2(1, Mathf.Sqrt(3) / 2);
|
||||||
public static readonly Vector3 DIR_N = new Vector3(0, 1, -1);
|
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));
|
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)
|
public HexCell(Vector3 cubeCoords)
|
||||||
|
|
Loading…
Reference in New Issue