| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Trailblazer.Pathing; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Describes how a single authoring token maps into chart and transition data. |
| | | 7 | | /// </summary> |
| | | 8 | | [Serializable] |
| | | 9 | | public readonly struct TraversalLegendEntry |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// The chart cell emitted for this token. |
| | | 13 | | /// </summary> |
| | | 14 | | public NavigationChartCell ChartCell { get; } |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Indicates which transition media this token may contribute when explicitly marked. |
| | | 18 | | /// </summary> |
| | | 19 | | public TraversalMedia TransitionMedia { get; } |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Returns true when this token may participate in generated transition anchors. |
| | | 23 | | /// </summary> |
| | 47 | 24 | | public bool HasTransitionMedia => TransitionMedia != TraversalMedia.None; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Creates a new legend entry with the specified chart output and optional transition-anchor output. |
| | | 28 | | /// </summary> |
| | | 29 | | /// <param name="chartCell">The chart cell emitted for this token.</param> |
| | | 30 | | /// <param name="transitionMedia"> |
| | | 31 | | /// The transition media emitted when this token is marked. |
| | | 32 | | /// These media must be a subset of the authored media declared by <paramref name="chartCell"/>. |
| | | 33 | | /// </param> |
| | | 34 | | public TraversalLegendEntry( |
| | | 35 | | NavigationChartCell chartCell, |
| | | 36 | | TraversalMedia transitionMedia = TraversalMedia.None) |
| | | 37 | | { |
| | 456 | 38 | | TraversalMedia authoredMedia = chartCell.TraversalKinds; |
| | 456 | 39 | | if ((transitionMedia & ~authoredMedia) != 0) |
| | | 40 | | { |
| | 1 | 41 | | throw new ArgumentException( |
| | 1 | 42 | | "Transition media must be a subset of the authored chart cell traversal media.", |
| | 1 | 43 | | nameof(transitionMedia)); |
| | | 44 | | } |
| | | 45 | | |
| | 455 | 46 | | ChartCell = chartCell; |
| | 455 | 47 | | TransitionMedia = transitionMedia; |
| | 455 | 48 | | } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// Creates an entry that contributes no chart traversal and no transition anchor. |
| | | 52 | | /// </summary> |
| | | 53 | | public static TraversalLegendEntry SkipCell() => |
| | 136 | 54 | | new(NavigationChartCell.Empty); |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Creates an entry that emits an authored solid cell and may participate in generated solid anchors. |
| | | 58 | | /// </summary> |
| | | 59 | | public static TraversalLegendEntry Solid(NavigationChartCell chartCell) => |
| | 45 | 60 | | new(chartCell, TraversalMedia.Solid); |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// Creates an entry that emits authored gas traversal data and an anchor when explicitly marked. |
| | | 64 | | /// </summary> |
| | | 65 | | public static TraversalLegendEntry Gas() => |
| | 46 | 66 | | new(NavigationChartCell.Gas, TraversalMedia.Gas); |
| | | 67 | | |
| | | 68 | | /// <summary> |
| | | 69 | | /// Creates an entry that emits authored liquid traversal data and an anchor when explicitly marked. |
| | | 70 | | /// </summary> |
| | | 71 | | public static TraversalLegendEntry Liquid() => |
| | 47 | 72 | | new(NavigationChartCell.Liquid, TraversalMedia.Liquid); |
| | | 73 | | } |