41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using System.Runtime.InteropServices;
|
|
|
|
namespace PkmnLibSharp.StaticData
|
|
{
|
|
[StructLayout(LayoutKind.Explicit)]
|
|
public readonly struct TypeIdentifier
|
|
{
|
|
// ReSharper disable once PrivateFieldCanBeConvertedToLocalVariable
|
|
[FieldOffset(0)] private readonly byte _identifier;
|
|
|
|
internal TypeIdentifier(byte b)
|
|
{
|
|
_identifier = b;
|
|
}
|
|
|
|
public bool Equals(TypeIdentifier other)
|
|
{
|
|
return _identifier == other._identifier;
|
|
}
|
|
|
|
public override bool Equals(object? obj)
|
|
{
|
|
return obj is TypeIdentifier other && Equals(other);
|
|
}
|
|
|
|
public override int GetHashCode()
|
|
{
|
|
return _identifier.GetHashCode();
|
|
}
|
|
|
|
public static bool operator ==(TypeIdentifier left, TypeIdentifier right)
|
|
{
|
|
return left.Equals(right);
|
|
}
|
|
|
|
public static bool operator !=(TypeIdentifier left, TypeIdentifier right)
|
|
{
|
|
return !left.Equals(right);
|
|
}
|
|
}
|
|
} |