| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationSelectedEdgeRef.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 | | using SwiftCollections.Utility; |
| | | 10 | | |
| | | 11 | | namespace Trailblazer.Pathing; |
| | | 12 | | |
| | | 13 | | /// <summary>Identifies one canonical outgoing edge without retaining snapshot-local state.</summary> |
| | | 14 | | internal readonly struct NavigationSelectedEdgeRef : IEquatable<NavigationSelectedEdgeRef> |
| | | 15 | | { |
| | | 16 | | internal NavigationSelectedEdgeRef( |
| | | 17 | | NavigationCellAddress target, |
| | | 18 | | TraversalMedium targetMedium, |
| | | 19 | | int canonicalOutgoingOrdinal) |
| | | 20 | | { |
| | | 21 | | System.Diagnostics.Debug.Assert(NavigationCell.IsKnownMedium(targetMedium)); |
| | 291972 | 22 | | Target = target; |
| | 291972 | 23 | | TargetMedium = targetMedium; |
| | 291972 | 24 | | CanonicalOutgoingOrdinal = canonicalOutgoingOrdinal; |
| | 291972 | 25 | | } |
| | | 26 | | |
| | | 27 | | internal NavigationCellAddress Target { get; } |
| | | 28 | | |
| | | 29 | | internal TraversalMedium TargetMedium { get; } |
| | | 30 | | |
| | | 31 | | internal int CanonicalOutgoingOrdinal { get; } |
| | | 32 | | |
| | 155 | 33 | | internal bool IsValid => !string.IsNullOrEmpty(Target.MapId) |
| | 155 | 34 | | && CanonicalOutgoingOrdinal >= 0; |
| | | 35 | | |
| | | 36 | | public bool Equals(NavigationSelectedEdgeRef other) => |
| | 122 | 37 | | Target.Equals(other.Target) |
| | 122 | 38 | | && TargetMedium == other.TargetMedium |
| | 122 | 39 | | && CanonicalOutgoingOrdinal == other.CanonicalOutgoingOrdinal; |
| | | 40 | | |
| | 100005 | 41 | | public override int GetHashCode() => SwiftHashTools.CombineHashCodes( |
| | 100005 | 42 | | SwiftHashTools.CombineHashCodes(Target.GetHashCode(), (int)TargetMedium), |
| | 100005 | 43 | | CanonicalOutgoingOrdinal); |
| | | 44 | | |
| | | 45 | | } |