SkinBOX.cs - Added ICloneable and IEquatable interfaces

This commit is contained in:
miku-666
2023-05-03 16:50:57 +02:00
parent fd37f8cfd4
commit cb7b4565f5

View File

@@ -20,7 +20,7 @@ using System.Numerics;
namespace PckStudio.Internal
{
public class SkinBOX
public class SkinBOX : ICloneable, IEquatable<SkinBOX>
{
public string Type;
public Vector3 Pos;
@@ -86,5 +86,28 @@ namespace PckStudio.Internal
float.TryParse(arguments[startIndex + 2], out float z);
return new Vector3(vec2, z);
}
public override int GetHashCode()
{
return Type.GetHashCode() % Pos.GetHashCode() * UV.GetHashCode() % Size.GetHashCode();
}
public override bool Equals(object obj)
{
return obj is SkinBOX box && Equals(box);
}
public bool Equals(SkinBOX other)
{
return Type.Equals(other.Type) &&
Pos.Equals(other.Pos) &&
Size.Equals(other.Size) &&
UV.Equals(other.UV);
}
public object Clone()
{
return new SkinBOX((string)Type.Clone(), Pos, Size, UV, HideWithArmor, Mirror, Scale);
}
}
}