| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Trailblazer.Pathing; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Represents the result of an A* pathfinding survey, including the computed waypoints and related metadata. |
| | | 7 | | /// </summary> |
| | | 8 | | /// <remarks> |
| | | 9 | | /// Use this class to access the waypoints generated by an A* pathfinding operation, along with |
| | | 10 | | /// information about the charts utilized and the validity of the result. |
| | | 11 | | /// The static Empty instance represents a result with no waypoints. |
| | | 12 | | /// </remarks> |
| | | 13 | | public class AStarSurveyResult : SurveyResult |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Gets the sequence of waypoints that define the calculated path. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <remarks> |
| | | 19 | | /// The array is empty if no path has been found or calculated. |
| | | 20 | | /// The waypoints are ordered from the start to the end of the path. |
| | | 21 | | /// </remarks> |
| | | 22 | | public AStarWaypoint[] Waypoints { get; private set; } = Array.Empty<AStarWaypoint>(); |
| | | 23 | | |
| | | 24 | | /// <inheritdoc/> |
| | 2259 | 25 | | public override bool HasPath => IsValid && Waypoints != null && Waypoints.Length > 0; |
| | | 26 | | |
| | | 27 | | /// <summary> |
| | | 28 | | /// Represents an empty result for an A* survey operation. |
| | | 29 | | /// </summary> |
| | 1 | 30 | | public static readonly AStarSurveyResult Empty = new(); |
| | | 31 | | |
| | 358 | 32 | | private AStarSurveyResult() { } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Creates a new instance of the AStarSurveyResult class with the specified waypoints, charts utilized, and key. |
| | | 36 | | /// </summary> |
| | | 37 | | /// <param name="context">The world context that owns the survey result.</param> |
| | | 38 | | /// <param name="waypoints">An array of AStarWaypoint objects representing the waypoints to include in the survey re |
| | | 39 | | /// <param name="chartsUtilized">An array of chart names that were utilized in the survey. If null, an empty array i |
| | | 40 | | /// <param name="key">The unique key associated with the survey request.</param> |
| | | 41 | | /// <returns>A new AStarSurveyResult instance initialized with the provided waypoints, charts utilized, and key.</re |
| | | 42 | | public static AStarSurveyResult Create( |
| | | 43 | | TrailblazerWorldContext context, |
| | | 44 | | AStarWaypoint[] waypoints, |
| | | 45 | | string[] chartsUtilized, |
| | | 46 | | int key) |
| | | 47 | | { |
| | 178 | 48 | | PathRequestContextResolver.ThrowIfUnusable(context); |
| | 178 | 49 | | return new AStarSurveyResult() |
| | 178 | 50 | | { |
| | 178 | 51 | | IsValid = true, |
| | 178 | 52 | | IsInUse = false, |
| | 178 | 53 | | Context = context, |
| | 178 | 54 | | ChartsUtilized = chartsUtilized ?? Array.Empty<string>(), |
| | 178 | 55 | | Waypoints = waypoints, |
| | 178 | 56 | | LastUsedFrame = -1, |
| | 178 | 57 | | RequestHashKey = key |
| | 178 | 58 | | }; |
| | | 59 | | } |
| | | 60 | | |
| | | 61 | | /// <inheritdoc/> |
| | | 62 | | public override void Reset() |
| | | 63 | | { |
| | 71 | 64 | | base.Reset(); |
| | 71 | 65 | | Waypoints = Array.Empty<AStarWaypoint>(); |
| | 71 | 66 | | } |
| | | 67 | | } |