| | | 1 | | using System; |
| | | 2 | | |
| | | 3 | | namespace Trailblazer.Pathing; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Owns guide result caches and reusable guide pools for one pathing context. |
| | | 7 | | /// </summary> |
| | | 8 | | internal sealed class TrailblazerGuideState : IDisposable |
| | | 9 | | { |
| | | 10 | | private bool _disposed; |
| | | 11 | | |
| | | 12 | | internal AStarSurveyor AStarSurveyor { get; } = new(); |
| | | 13 | | |
| | | 14 | | internal FlowFieldSurveyor FlowFieldSurveyor { get; } = new(); |
| | | 15 | | |
| | | 16 | | internal VolumeSurveyor VolumeSurveyor { get; } = new(); |
| | | 17 | | |
| | | 18 | | internal ReusableSurveyResultCache<AStarSurveyResult> CachedAStarResults { get; } = new(); |
| | | 19 | | |
| | | 20 | | internal ReusableSurveyResultCache<FlowFieldSurveyResult> CachedFlowResults { get; } = new(); |
| | | 21 | | |
| | | 22 | | internal ReusableSurveyResultCache<VolumeSurveyResult> CachedVolumeResults { get; } = new(); |
| | | 23 | | |
| | | 24 | | internal ReusableSurveyResultCache<HybridRoutePlanSurveyResult> CachedHybridRoutePlans { get; } = new(); |
| | | 25 | | |
| | | 26 | | internal GuidePool<AStarGuide> AStarGuides { get; } = |
| | 961 | 27 | | new(static () => new AStarGuide(), static guide => guide.ResetForReuse()); |
| | | 28 | | |
| | | 29 | | internal GuidePool<FlowFieldGuide> FlowFieldGuides { get; } = |
| | 961 | 30 | | new(static () => new FlowFieldGuide(), static guide => guide.ResetForReuse()); |
| | | 31 | | |
| | | 32 | | internal GuidePool<VolumeGuide> VolumeGuides { get; } = |
| | 961 | 33 | | new(static () => new VolumeGuide(), static guide => guide.ResetForReuse()); |
| | | 34 | | |
| | | 35 | | public void Dispose() |
| | | 36 | | { |
| | 961 | 37 | | if (_disposed) |
| | 0 | 38 | | return; |
| | | 39 | | |
| | 961 | 40 | | _disposed = true; |
| | 961 | 41 | | CachedAStarResults.Dispose(); |
| | 961 | 42 | | CachedFlowResults.Dispose(); |
| | 961 | 43 | | CachedVolumeResults.Dispose(); |
| | 961 | 44 | | CachedHybridRoutePlans.Dispose(); |
| | 961 | 45 | | } |
| | | 46 | | } |