| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationFlowFieldPayloadKey.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 destination-centric flow field independently of origin.</summary> |
| | | 14 | | internal readonly struct NavigationFlowFieldPayloadKey : |
| | | 15 | | IEquatable<NavigationFlowFieldPayloadKey> |
| | | 16 | | { |
| | | 17 | | internal NavigationFlowFieldPayloadKey( |
| | | 18 | | PathQuery query, |
| | | 19 | | NavigationCellAddress destinationAddress, |
| | | 20 | | TraversalMedium startMedium, |
| | | 21 | | TraversalMedia targetMedia) |
| | | 22 | | { |
| | 774 | 23 | | Destination = query.End; |
| | 774 | 24 | | DestinationAddress = destinationAddress; |
| | 774 | 25 | | _startMedium = (byte)startMedium; |
| | 774 | 26 | | _targetMedia = (byte)targetMedia; |
| | 774 | 27 | | Agent = query.Agent; |
| | 774 | 28 | | AreaPolicy = query.AreaPolicy; |
| | 774 | 29 | | Traversal = query.Traversal; |
| | 774 | 30 | | Budget = query.Budget; |
| | 774 | 31 | | AllowTransitions = query.AllowTransitions; |
| | 774 | 32 | | FlowField = query.FlowField; |
| | 774 | 33 | | } |
| | | 34 | | |
| | | 35 | | internal NavigationEndpoint Destination { get; } |
| | | 36 | | internal NavigationCellAddress DestinationAddress { get; } |
| | | 37 | | internal NavigationAgentProfile Agent { get; } |
| | | 38 | | internal NavigationAreaPolicyKey AreaPolicy { get; } |
| | | 39 | | internal TraversalIntent Traversal { get; } |
| | | 40 | | internal NavigationWorkBudget Budget { get; } |
| | | 41 | | internal bool AllowTransitions { get; } |
| | | 42 | | private readonly byte _startMedium; |
| | | 43 | | private readonly byte _targetMedia; |
| | 8806 | 44 | | internal TraversalMedium StartMedium => (TraversalMedium)_startMedium; |
| | 4809 | 45 | | internal TraversalMedia TargetMedia => (TraversalMedia)_targetMedia; |
| | | 46 | | internal FlowFieldQueryOptions FlowField { get; } |
| | | 47 | | |
| | | 48 | | public bool Equals(NavigationFlowFieldPayloadKey other) => |
| | 1432 | 49 | | Destination == other.Destination |
| | 1432 | 50 | | && DestinationAddress == other.DestinationAddress |
| | 1432 | 51 | | && StartMedium == other.StartMedium |
| | 1432 | 52 | | && TargetMedia == other.TargetMedia |
| | 1432 | 53 | | && Agent == other.Agent |
| | 1432 | 54 | | && AreaPolicy == other.AreaPolicy |
| | 1432 | 55 | | && Traversal == other.Traversal |
| | 1432 | 56 | | && Budget == other.Budget |
| | 1432 | 57 | | && AllowTransitions == other.AllowTransitions |
| | 1432 | 58 | | && FlowField == other.FlowField; |
| | | 59 | | |
| | | 60 | | public override int GetHashCode() |
| | | 61 | | { |
| | 1938 | 62 | | int hash = SwiftHashTools.CombineHashCodes( |
| | 1938 | 63 | | Destination.GetHashCode(), |
| | 1938 | 64 | | DestinationAddress.GetHashCode()); |
| | 1938 | 65 | | hash = SwiftHashTools.CombineHashCodes(hash, (int)StartMedium); |
| | 1938 | 66 | | hash = SwiftHashTools.CombineHashCodes(hash, (int)TargetMedia); |
| | 1938 | 67 | | hash = SwiftHashTools.CombineHashCodes(hash, Agent.GetHashCode()); |
| | 1938 | 68 | | hash = SwiftHashTools.CombineHashCodes(hash, AreaPolicy.GetHashCode()); |
| | 1938 | 69 | | hash = SwiftHashTools.CombineHashCodes(hash, Traversal.GetHashCode()); |
| | 1938 | 70 | | hash = SwiftHashTools.CombineHashCodes(hash, Budget.GetHashCode()); |
| | 1938 | 71 | | hash = SwiftHashTools.CombineHashCodes(hash, AllowTransitions ? 1 : 0); |
| | 1938 | 72 | | return SwiftHashTools.CombineHashCodes(hash, FlowField.GetHashCode()); |
| | | 73 | | } |
| | | 74 | | |
| | | 75 | | } |