| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationAreaId.cs |
| | | 3 | | //======================================================================= |
| | | 4 | | // MIT License, Copyright (c) 2024-present David Oravsky (mrdav30) |
| | | 5 | | // See LICENSE file in the project root for full license information. |
| | | 6 | | //======================================================================= |
| | | 7 | | |
| | | 8 | | using System; |
| | | 9 | | |
| | | 10 | | namespace Trailblazer.Pathing; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Identifies one host-defined navigation area independently of registration order. |
| | | 14 | | /// </summary> |
| | | 15 | | public readonly struct NavigationAreaId : IEquatable<NavigationAreaId>, IComparable<NavigationAreaId> |
| | | 16 | | { |
| | | 17 | | /// <summary>Creates an explicitly assigned host-defined area identifier.</summary> |
| | | 18 | | public NavigationAreaId(ushort value) |
| | | 19 | | { |
| | 40 | 20 | | Value = value; |
| | 40 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <summary>Gets the stable numeric identifier. Zero denotes the default area.</summary> |
| | | 24 | | public ushort Value { get; } |
| | | 25 | | |
| | | 26 | | /// <inheritdoc/> |
| | 1 | 27 | | public int CompareTo(NavigationAreaId other) => Value.CompareTo(other.Value); |
| | | 28 | | |
| | | 29 | | /// <inheritdoc/> |
| | 67 | 30 | | public bool Equals(NavigationAreaId other) => Value == other.Value; |
| | | 31 | | |
| | | 32 | | /// <inheritdoc/> |
| | 16 | 33 | | public override bool Equals(object? obj) => obj is NavigationAreaId other && Equals(other); |
| | | 34 | | |
| | | 35 | | /// <inheritdoc/> |
| | 16 | 36 | | public override int GetHashCode() => Value; |
| | | 37 | | |
| | | 38 | | /// <inheritdoc/> |
| | 1 | 39 | | public override string ToString() => Value.ToString(System.Globalization.CultureInfo.InvariantCulture); |
| | | 40 | | |
| | | 41 | | /// <summary>Tests two identifiers for equality.</summary> |
| | 51 | 42 | | public static bool operator ==(NavigationAreaId left, NavigationAreaId right) => left.Equals(right); |
| | | 43 | | |
| | | 44 | | /// <summary>Tests two identifiers for inequality.</summary> |
| | 1 | 45 | | public static bool operator !=(NavigationAreaId left, NavigationAreaId right) => !left.Equals(right); |
| | | 46 | | } |