| | | 1 | | using Trailblazer.Pathing; |
| | | 2 | | |
| | | 3 | | namespace Trailblazer.Navigation; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Resolves whether a guided request or handoff currently implies climb intent. |
| | | 7 | | /// </summary> |
| | | 8 | | internal static class GuidedClimbIntentResolver |
| | | 9 | | { |
| | | 10 | | public static bool Resolve(IPathRequest pathRequest, GuidedVolumeExitHandoff? handoff = null) |
| | | 11 | | { |
| | 71 | 12 | | if (handoff != null |
| | 71 | 13 | | && !string.IsNullOrEmpty(handoff.TransitionId) |
| | 71 | 14 | | && TraversalTransitionRegistry.TryGet(handoff.TransitionId, out TraversalTransition transition)) |
| | | 15 | | { |
| | 12 | 16 | | return transition.RequestsClimbIntent; |
| | | 17 | | } |
| | | 18 | | |
| | 59 | 19 | | return pathRequest switch |
| | 59 | 20 | | { |
| | 36 | 21 | | AStarPathRequest aStar when aStar.AllowTraversalTransitions => |
| | 22 | 22 | | RequestsClimbIntent(HybridPathRequest.CreateFromAStar(aStar)), |
| | 7 | 23 | | FlowFieldPathRequest flowField when flowField.AllowTraversalTransitions => |
| | 6 | 24 | | RequestsClimbIntent(HybridPathRequest.CreateFromFlowField(flowField)), |
| | 0 | 25 | | HybridPathRequest hybrid => RequestsClimbIntent(hybrid), |
| | 31 | 26 | | _ => false |
| | 59 | 27 | | }; |
| | | 28 | | } |
| | | 29 | | |
| | | 30 | | private static bool RequestsClimbIntent(HybridPathRequest? request) |
| | | 31 | | { |
| | 28 | 32 | | if (request == null) |
| | 0 | 33 | | return false; |
| | | 34 | | |
| | 28 | 35 | | TraversalTransition[]? directedTransitions = request.RoutePlan?.DirectedTransitions; |
| | 28 | 36 | | if (directedTransitions == null) |
| | 0 | 37 | | return false; |
| | | 38 | | |
| | 92 | 39 | | for (int i = 0; i < directedTransitions.Length; i++) |
| | | 40 | | { |
| | 26 | 41 | | if (directedTransitions[i].RequestsClimbIntent) |
| | 8 | 42 | | return true; |
| | | 43 | | } |
| | | 44 | | |
| | 20 | 45 | | return false; |
| | | 46 | | } |
| | | 47 | | } |