| | | 1 | | using GridForge.Grids; |
| | | 2 | | using GridForge.Spatial; |
| | | 3 | | using SwiftCollections; |
| | | 4 | | using SwiftCollections.Pool; |
| | | 5 | | using System; |
| | | 6 | | using System.Threading; |
| | | 7 | | |
| | | 8 | | namespace Trailblazer.Pathing; |
| | | 9 | | |
| | | 10 | | /// <summary> |
| | | 11 | | /// Owns mutable pathing state for one <see cref="TrailblazerWorldContext"/>. |
| | | 12 | | /// </summary> |
| | | 13 | | internal sealed class PathingWorldState : IDisposable |
| | | 14 | | { |
| | | 15 | | private bool _disposed; |
| | | 16 | | |
| | 961 | 17 | | internal PathingWorldState(TrailblazerWorldContext context) |
| | | 18 | | { |
| | 961 | 19 | | Context = context; |
| | 961 | 20 | | ExternalGridBridge = new PathingWorldGridBridge(this); |
| | 961 | 21 | | } |
| | | 22 | | |
| | | 23 | | internal TrailblazerWorldContext Context { get; } |
| | | 24 | | |
| | 41077 | 25 | | internal GridWorld World => Context.World; |
| | | 26 | | |
| | | 27 | | internal PathingWorldGridBridge ExternalGridBridge { get; } |
| | | 28 | | |
| | | 29 | | internal SwiftObjectPool<SolidChartPartition> PartitionPool { get; } = new( |
| | | 30 | | () => new SolidChartPartition(), |
| | | 31 | | actionOnRelease: partition => partition.Reset()); |
| | | 32 | | |
| | | 33 | | internal SwiftObjectPool<VolumeChartPartition> VolumeChartPartitionPool { get; } = new( |
| | | 34 | | () => new VolumeChartPartition(), |
| | | 35 | | actionOnRelease: partition => partition.Reset()); |
| | | 36 | | |
| | | 37 | | internal SwiftDictionary<string, NavigationChartRegistration> NavigationChartMap { get; } = new(); |
| | | 38 | | |
| | | 39 | | internal SwiftDictionary<WorldVoxelIndex, ResolvedChartVoxelState> ResolvedChartVoxelStates { get; } = new(); |
| | | 40 | | |
| | | 41 | | internal SwiftDictionary<ushort, SwiftDictionary<string, int>> InitializedChartTouchCountsByGridIndex { get; } = new |
| | | 42 | | |
| | | 43 | | internal ReaderWriterLockSlim NavigationChartMapLock { get; } = new(); |
| | | 44 | | |
| | | 45 | | internal int ActiveAuthoredGasCellCount { get; set; } |
| | | 46 | | |
| | | 47 | | internal int ActiveAuthoredLiquidCellCount { get; set; } |
| | | 48 | | |
| | | 49 | | internal int NextChartRegistrationOrder { get; set; } |
| | | 50 | | |
| | | 51 | | internal TraversalTransitionRegistryState TransitionRegistryState { get; } = new(); |
| | | 52 | | |
| | | 53 | | internal TraversalTransitionQueryCache TransitionQueryCache { get; } = new(); |
| | | 54 | | |
| | | 55 | | internal VolumeMediumRulesState VolumeRulesState { get; } = new(); |
| | | 56 | | |
| | | 57 | | internal SolidPartitionReachabilityState ReachabilityState { get; } = new(); |
| | | 58 | | |
| | | 59 | | internal TrailblazerGuideState GuideState { get; } = new(); |
| | | 60 | | |
| | | 61 | | internal AlternativeVoxelFinder AlternativeVoxelFinder { get; } = new(); |
| | | 62 | | |
| | | 63 | | internal SwiftDictionary<ushort, ExternalGridEventObservation> ExternalGridEventObservationsByGridIndex { get; } = n |
| | | 64 | | |
| | | 65 | | internal SwiftDictionary<ushort, PendingExternalGridChange> PendingGridChangesByGridIndex { get; } = new(); |
| | | 66 | | |
| | | 67 | | internal SwiftList<ushort> PendingGridChangeOrder { get; } = new(); |
| | | 68 | | |
| | | 69 | | internal int GridEventsReceived { get; set; } |
| | | 70 | | |
| | | 71 | | internal int GridAddEventsReceived { get; set; } |
| | | 72 | | |
| | | 73 | | internal int GridRemoveEventsReceived { get; set; } |
| | | 74 | | |
| | | 75 | | internal int GridChangeEventsReceived { get; set; } |
| | | 76 | | |
| | | 77 | | internal int DistinctObservedGridSlots { get; set; } |
| | | 78 | | |
| | | 79 | | internal int DuplicateGridEventSignaturesObserved { get; set; } |
| | | 80 | | |
| | | 81 | | internal int DuplicateGridAddEventSignaturesObserved { get; set; } |
| | | 82 | | |
| | | 83 | | internal int DuplicateGridRemoveEventSignaturesObserved { get; set; } |
| | | 84 | | |
| | | 85 | | internal int DuplicateGridChangeEventSignaturesObserved { get; set; } |
| | | 86 | | |
| | | 87 | | internal int MaxGridEventStreak { get; set; } |
| | | 88 | | |
| | | 89 | | internal int GridRebuildPassesExecuted { get; set; } |
| | | 90 | | |
| | | 91 | | internal int GridEventsIgnoredForNoIntersectingCharts { get; set; } |
| | | 92 | | |
| | | 93 | | internal int TotalChartsSelectedForGridRebuild { get; set; } |
| | | 94 | | |
| | | 95 | | internal int MaxChartsSelectedForSingleGridEvent { get; set; } |
| | | 96 | | |
| | | 97 | | public void Dispose() |
| | | 98 | | { |
| | 961 | 99 | | if (_disposed) |
| | 0 | 100 | | return; |
| | | 101 | | |
| | 961 | 102 | | _disposed = true; |
| | 961 | 103 | | ExternalGridBridge.Dispose(); |
| | 961 | 104 | | GuideState.Dispose(); |
| | 961 | 105 | | TransitionRegistryState.Dispose(); |
| | 961 | 106 | | NavigationChartMapLock.Dispose(); |
| | 961 | 107 | | } |
| | | 108 | | } |