< Summary

Information
Class: Trailblazer.Pathing.NavigationAStarWorkspace
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/AStar/NavigationAStarWorkspace.cs
Line coverage
100%
Covered lines: 51
Uncovered lines: 0
Coverable lines: 51
Total lines: 102
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%88100%
get_EndpointPages()100%11100%
get_EndpointComponents()100%11100%
get_EndpointPageCount()100%11100%
get_EndpointComponentCount()100%11100%
Reset()100%11100%
TryRecordEndpointComponent(...)100%11100%
ResetSearch()100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Search/AStar/NavigationAStarWorkspace.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationAStarWorkspace.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024-present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using System;
 9
 10namespace Trailblazer.Pathing;
 11
 12/// <summary>Owns the reusable bounded buffers for one exclusive graph A* query.</summary>
 13internal sealed class NavigationAStarWorkspace
 14{
 805215    internal NavigationAStarWorkspace(
 805216        int mapCapacity,
 805217        int endpointPageCapacity,
 805218        int componentCapacity,
 805219        int nodeCapacity,
 805220        int rayCoveredAddressCapacity,
 805221        int rayTraceIntervalCapacity,
 805222        int guidePointCapacity)
 23    {
 805224        SwiftThrowHelper.ThrowIfNegative(mapCapacity, nameof(mapCapacity));
 805225        SwiftThrowHelper.ThrowIfNegative(endpointPageCapacity, nameof(endpointPageCapacity));
 805226        SwiftThrowHelper.ThrowIfNegative(nodeCapacity, nameof(nodeCapacity));
 805227        SwiftThrowHelper.ThrowIfNegative(componentCapacity, nameof(componentCapacity));
 805228        SwiftThrowHelper.ThrowIfNegative(guidePointCapacity, nameof(guidePointCapacity));
 805229        EndpointWorkspace = new NavigationEndpointWorkspace(
 805230            mapCapacity,
 805231            endpointPageCapacity,
 805232            componentCapacity);
 805233        NodeTable = new NavigationAStarNodeTable(nodeCapacity);
 805234        HeapNodes = nodeCapacity == 0
 805235            ? Array.Empty<NavigationMediumStateRef>()
 805236            : new NavigationMediumStateRef[nodeCapacity];
 805237        PathNodes = nodeCapacity == 0
 805238            ? Array.Empty<NavigationMediumStateRef>()
 805239            : new NavigationMediumStateRef[nodeCapacity];
 805240        PathNodeGuidePointOrdinals = nodeCapacity == 0
 805241            ? Array.Empty<int>()
 805242            : new int[nodeCapacity];
 805243        RayWorkspace = new NavigationRayWorkspace(
 805244            mapCapacity,
 805245            endpointPageCapacity,
 805246            componentCapacity,
 805247            rayCoveredAddressCapacity,
 805248            rayTraceIntervalCapacity);
 805249        GuidePoints = guidePointCapacity == 0
 805250            ? Array.Empty<NavigationAStarGuidePoint>()
 805251            : new NavigationAStarGuidePoint[guidePointCapacity];
 805252    }
 53
 54    internal NavigationEndpointWorkspace EndpointWorkspace { get; }
 55
 45456    internal GraphPageDependencyAddress[] EndpointPages => EndpointWorkspace.Pages;
 57
 58    internal NavigationSurfaceComponentKey[] EndpointComponents =>
 45459        EndpointWorkspace.Components;
 60
 63061    internal int EndpointPageCount => EndpointWorkspace.PageCount;
 62
 63163    internal int EndpointComponentCount => EndpointWorkspace.ComponentCount;
 64
 65    internal NavigationAStarNodeTable NodeTable { get; }
 66
 67    internal NavigationMediumStateRef[] HeapNodes { get; }
 68
 69    internal NavigationMediumStateRef[] PathNodes { get; }
 70
 71    internal int[] PathNodeGuidePointOrdinals { get; }
 72
 73    internal NavigationRayWorkspace RayWorkspace { get; }
 74
 75    internal NavigationAStarGuidePoint[] GuidePoints { get; }
 76
 77    internal int HeapCount { get; set; }
 78
 79    internal int PathNodeCount { get; set; }
 80
 81    internal int GuidePointCount { get; set; }
 82
 83    internal void Reset()
 84    {
 285        EndpointWorkspace.Reset();
 286        RayWorkspace.Reset();
 287        ResetSearch();
 288    }
 89
 90    internal bool TryRecordEndpointComponent(NavigationSurfaceComponentKey componentKey)
 91    {
 392        return EndpointWorkspace.TryRecordComponent(componentKey);
 93    }
 94
 95    internal void ResetSearch()
 96    {
 25197        NodeTable.Reset();
 25198        HeapCount = 0;
 25199        PathNodeCount = 0;
 251100        GuidePointCount = 0;
 251101    }
 102}