| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationTransitionInstruction.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 FixedMathSharp; |
| | | 9 | | |
| | | 10 | | namespace Trailblazer.Pathing; |
| | | 11 | | |
| | | 12 | | /// <summary>Describes one exact semantic action selected by a navigation guide.</summary> |
| | | 13 | | public readonly struct NavigationTransitionInstruction |
| | | 14 | | { |
| | | 15 | | internal NavigationTransitionInstruction( |
| | | 16 | | NavigationTransitionIdentityKind identityKind, |
| | | 17 | | string ownerMapId, |
| | | 18 | | string id, |
| | | 19 | | TraversalTransitionType type, |
| | | 20 | | NavigationCellAddress sourceAddress, |
| | | 21 | | NavigationCellAddress destinationAddress, |
| | | 22 | | TraversalMedium sourceMedium, |
| | | 23 | | TraversalMedium destinationMedium, |
| | | 24 | | Vector3d sourcePosition, |
| | | 25 | | Vector3d destinationPosition, |
| | | 26 | | TraversalTransitionLocomotionHints locomotionHints, |
| | | 27 | | object? completionOwner = null, |
| | | 28 | | ulong acquisitionGeneration = 0, |
| | | 29 | | long stepOrdinal = -1) |
| | | 30 | | { |
| | 3151 | 31 | | IdentityKind = identityKind; |
| | 3151 | 32 | | OwnerMapId = ownerMapId; |
| | 3151 | 33 | | Id = id; |
| | 3151 | 34 | | Type = type; |
| | 3151 | 35 | | SourceAddress = sourceAddress; |
| | 3151 | 36 | | DestinationAddress = destinationAddress; |
| | 3151 | 37 | | SourceMedium = sourceMedium; |
| | 3151 | 38 | | DestinationMedium = destinationMedium; |
| | 3151 | 39 | | SourcePosition = sourcePosition; |
| | 3151 | 40 | | DestinationPosition = destinationPosition; |
| | 3151 | 41 | | LocomotionHints = locomotionHints; |
| | 3151 | 42 | | CompletionOwner = completionOwner; |
| | 3151 | 43 | | AcquisitionGeneration = acquisitionGeneration; |
| | 3151 | 44 | | StepOrdinal = stepOrdinal; |
| | 3151 | 45 | | } |
| | | 46 | | |
| | | 47 | | /// <summary>Gets whether the stable ID belongs to a definition or a rule.</summary> |
| | | 48 | | public NavigationTransitionIdentityKind IdentityKind { get; } |
| | | 49 | | |
| | | 50 | | /// <summary>Gets the explicit definition owner map ID, or an empty string for a rule.</summary> |
| | | 51 | | public string OwnerMapId { get; } |
| | | 52 | | |
| | | 53 | | /// <summary>Gets the stable transition definition or rule ID.</summary> |
| | | 54 | | public string Id { get; } |
| | | 55 | | |
| | | 56 | | /// <summary>Gets the authored semantic action type.</summary> |
| | | 57 | | public TraversalTransitionType Type { get; } |
| | | 58 | | |
| | | 59 | | /// <summary>Gets the exact source-cell address.</summary> |
| | | 60 | | public NavigationCellAddress SourceAddress { get; } |
| | | 61 | | |
| | | 62 | | /// <summary>Gets the exact destination-cell address.</summary> |
| | | 63 | | public NavigationCellAddress DestinationAddress { get; } |
| | | 64 | | |
| | | 65 | | /// <summary>Gets the exact source medium.</summary> |
| | | 66 | | public TraversalMedium SourceMedium { get; } |
| | | 67 | | |
| | | 68 | | /// <summary>Gets the exact destination medium.</summary> |
| | | 69 | | public TraversalMedium DestinationMedium { get; } |
| | | 70 | | |
| | | 71 | | /// <summary>Gets the exact source action position.</summary> |
| | | 72 | | public Vector3d SourcePosition { get; } |
| | | 73 | | |
| | | 74 | | /// <summary>Gets the exact destination action position.</summary> |
| | | 75 | | public Vector3d DestinationPosition { get; } |
| | | 76 | | |
| | | 77 | | /// <summary>Gets the authored built-in locomotion hints.</summary> |
| | | 78 | | public TraversalTransitionLocomotionHints LocomotionHints { get; } |
| | | 79 | | |
| | | 80 | | private ulong AcquisitionGeneration { get; } |
| | | 81 | | |
| | | 82 | | private long StepOrdinal { get; } |
| | | 83 | | |
| | | 84 | | private object? CompletionOwner { get; } |
| | | 85 | | |
| | | 86 | | internal NavigationTransitionInstruction WithCompletionStamp( |
| | | 87 | | object completionOwner, |
| | | 88 | | ulong acquisitionGeneration, |
| | 3069 | 89 | | long stepOrdinal) => new( |
| | 3069 | 90 | | IdentityKind, |
| | 3069 | 91 | | OwnerMapId, |
| | 3069 | 92 | | Id, |
| | 3069 | 93 | | Type, |
| | 3069 | 94 | | SourceAddress, |
| | 3069 | 95 | | DestinationAddress, |
| | 3069 | 96 | | SourceMedium, |
| | 3069 | 97 | | DestinationMedium, |
| | 3069 | 98 | | SourcePosition, |
| | 3069 | 99 | | DestinationPosition, |
| | 3069 | 100 | | LocomotionHints, |
| | 3069 | 101 | | completionOwner, |
| | 3069 | 102 | | acquisitionGeneration, |
| | 3069 | 103 | | stepOrdinal); |
| | | 104 | | |
| | | 105 | | internal bool MatchesCompletion( |
| | | 106 | | object completionOwner, |
| | | 107 | | ulong acquisitionGeneration, |
| | | 108 | | long stepOrdinal) => |
| | 41 | 109 | | ReferenceEquals(CompletionOwner, completionOwner) |
| | 41 | 110 | | && AcquisitionGeneration == acquisitionGeneration |
| | 41 | 111 | | && StepOrdinal == stepOrdinal; |
| | | 112 | | } |