PkmnLib.NET/PkmnLib.Static/TypeIdentifier.cs
Deukhoofd 8a857ed232
All checks were successful
Build / Build (push) Successful in 51s
Implements some micro-optimizations
2025-07-05 15:46:32 +02:00

39 lines
1.1 KiB
C#

using PkmnLib.Static.Libraries;
using PkmnLib.Static.Utils;
namespace PkmnLib.Static;
/// <summary>
/// A number that identifies a type. To be used with <see cref="TypeLibrary"/>
/// </summary>
public readonly struct TypeIdentifier : IEquatable<TypeIdentifier>
{
/// <summary>
/// The name of the type identifier.
/// </summary>
public StringKey Name { get; }
/// <summary>
/// The underlying value of the type identifier.
/// </summary>
public byte Value { get; }
/// <inheritdoc cref="TypeIdentifier"/>
public TypeIdentifier(byte value, StringKey name)
{
Value = value;
Name = name;
}
/// <inheritdoc />
public override int GetHashCode() => Value.GetHashCode();
/// <inheritdoc />
public bool Equals(TypeIdentifier other) => Value == other.Value;
/// <inheritdoc />
public override bool Equals(object? obj) => obj is TypeIdentifier other && Equals(other);
public static bool operator ==(TypeIdentifier left, TypeIdentifier right) => left.Equals(right);
public static bool operator !=(TypeIdentifier left, TypeIdentifier right) => !left.Equals(right);
}