| | | 1 | | using SwiftCollections; |
| | | 2 | | using System; |
| | | 3 | | |
| | | 4 | | namespace Trailblazer.Pathing; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Stores live registration state for one authored <see cref="NavigationChart"/> inside a pathing owner. |
| | | 8 | | /// </summary> |
| | | 9 | | /// <remarks> |
| | | 10 | | /// Authored chart data is reusable. Initialization state, same-priority overlap order, and managed |
| | | 11 | | /// generated transition ids belong to the registration owned by a runtime context. |
| | | 12 | | /// </remarks> |
| | | 13 | | public sealed class NavigationChartRegistration |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Creates live registration state for an authored chart. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="chart">The authored chart data.</param> |
| | | 19 | | /// <param name="registrationOrder">The deterministic order assigned by the owner.</param> |
| | | 20 | | /// <param name="generatedTransitionIdPrefix">The prefix used for generated transition ids.</param> |
| | 921 | 21 | | public NavigationChartRegistration( |
| | 921 | 22 | | NavigationChart chart, |
| | 921 | 23 | | int registrationOrder, |
| | 921 | 24 | | string generatedTransitionIdPrefix) |
| | | 25 | | { |
| | 921 | 26 | | Chart = chart ?? throw new ArgumentNullException(nameof(chart)); |
| | 921 | 27 | | if (string.IsNullOrWhiteSpace(generatedTransitionIdPrefix)) |
| | | 28 | | { |
| | 3 | 29 | | throw new ArgumentException( |
| | 3 | 30 | | "Generated transition id prefix cannot be null or whitespace.", |
| | 3 | 31 | | nameof(generatedTransitionIdPrefix)); |
| | | 32 | | } |
| | | 33 | | |
| | 918 | 34 | | RegistrationOrder = registrationOrder; |
| | 918 | 35 | | TransitionIdPrefix = generatedTransitionIdPrefix; |
| | 918 | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// Gets the authored chart data. |
| | | 40 | | /// </summary> |
| | | 41 | | public NavigationChart Chart { get; } |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// Gets the deterministic registration order. Higher values win same-priority chart overlaps. |
| | | 45 | | /// </summary> |
| | | 46 | | public int RegistrationOrder { get; } |
| | | 47 | | |
| | | 48 | | /// <summary> |
| | | 49 | | /// Gets whether the chart is currently materialized into live voxel state for this registration. |
| | | 50 | | /// </summary> |
| | | 51 | | public bool IsInitialized { get; internal set; } |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// Gets the generated transition id prefix for this chart registration. |
| | | 55 | | /// </summary> |
| | | 56 | | internal string TransitionIdPrefix { get; } |
| | | 57 | | |
| | | 58 | | /// <summary> |
| | | 59 | | /// Gets the priority used for managed generated transitions created by this chart registration. |
| | | 60 | | /// </summary> |
| | 4 | 61 | | internal int Priority => Chart.Priority; |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// Gets the managed generated transition ids currently associated with this registration. |
| | | 65 | | /// </summary> |
| | | 66 | | internal SwiftHashSet<string> TransitionIds { get; } = new(); |
| | | 67 | | } |