< Summary

Information
Class: Trailblazer.Pathing.NavigationGraphCellDiagnostic
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/NavigationGraphDiagnosticsSnapshot.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 247
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_IsBlocked()100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/NavigationGraphDiagnosticsSnapshot.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationGraphDiagnosticsSnapshot.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.Collections.Generic;
 9using System.Collections.ObjectModel;
 10using GridForge.Configuration;
 11using GridForge.Grids.Storage;
 12using GridForge.Grids.Topology;
 13using GridForge.Spatial;
 14
 15namespace Trailblazer.Pathing;
 16
 17/// <summary>Identifies the semantic source of one effective graph cell.</summary>
 18public enum NavigationCellSemanticSource
 19{
 20    /// <summary>The effective value comes from the immutable map bake.</summary>
 21    Baked = 0,
 22    /// <summary>A semantic overlay supplies the effective payload.</summary>
 23    OverlaySet = 1,
 24    /// <summary>A semantic overlay tombstones traversal at the address.</summary>
 25    OverlaySuppressed = 2,
 26    /// <summary>A semantic overlay owns an unbaked dynamic cell slot.</summary>
 27    DynamicOverlaySet = 3,
 28    /// <summary>An unbaked dynamic slot remains reserved but has no effective payload.</summary>
 29    DynamicInactive = 4
 30}
 31
 32/// <summary>Copies one addressed composed cell for bounded diagnostics.</summary>
 33public readonly struct NavigationGraphCellDiagnostic
 34{
 35    internal NavigationGraphCellDiagnostic(
 36        VoxelIndex index,
 37        int slot,
 38        NavigationCellSemanticSource semanticSource,
 39        bool hasCell,
 40        NavigationCell cell,
 41        bool isPresent,
 42        byte obstacleCount)
 43    {
 214503944        Index = index;
 214503945        Slot = slot;
 214503946        SemanticSource = semanticSource;
 214503947        HasCell = hasCell;
 214503948        Cell = cell;
 214503949        IsPresent = isPresent;
 214503950        ObstacleCount = obstacleCount;
 214503951    }
 52
 53    /// <summary>Gets the topology-local address.</summary>
 54    public VoxelIndex Index { get; }
 55    /// <summary>Gets the stable map-local baked or dynamic slot.</summary>
 56    public int Slot { get; }
 57    /// <summary>Gets the baked, override, tombstone, or dynamic source.</summary>
 58    public NavigationCellSemanticSource SemanticSource { get; }
 59    /// <summary>Gets whether the address has an effective semantic cell.</summary>
 60    public bool HasCell { get; }
 61    /// <summary>Gets the effective cell payload when <see cref="HasCell"/> is true.</summary>
 62    public NavigationCell Cell { get; }
 63    /// <summary>Gets the mirrored GridForge presence state.</summary>
 64    public bool IsPresent { get; }
 65    /// <summary>Gets the mirrored exact obstacle count.</summary>
 66    public byte ObstacleCount { get; }
 67    /// <summary>Gets whether physical blockage suppresses traversal.</summary>
 268    public bool IsBlocked => ObstacleCount > 0;
 69}
 70
 71/// <summary>Copies one map instance and its bounded addressed diagnostics.</summary>
 72public sealed class NavigationGraphMapDiagnostic
 73{
 74    private readonly ReadOnlyCollection<NavigationGraphCellDiagnostic> _cells;
 75
 76    internal NavigationGraphMapDiagnostic(
 77        string mapId,
 78        long bakeVersion,
 79        long instanceVersion,
 80        long overlayHighWaterSequence,
 81        long physicalVersion,
 82        int componentId,
 83        long componentVersion,
 84        int incidentExplicitEdgeCount,
 85        bool isMaterialized,
 86        long worldSpawnToken,
 87        long gridSpawnToken,
 88        GridConfigurationKey configurationKey,
 89        GridTopologyKind topologyKind,
 90        GridStorageKind storageKind,
 91        NavigationCellLookupKind lookupKind,
 92        int bakedSlotCount,
 93        int dynamicSlotCount,
 94        long retainedBytes,
 95        int lastBaselineAddressCount,
 96        int lastCopiedSemanticPages,
 97        int lastCopiedPhysicalPages,
 98        NavigationGraphCellDiagnostic[] cells)
 99    {
 100        MapId = mapId;
 101        BakeVersion = bakeVersion;
 102        InstanceVersion = instanceVersion;
 103        OverlayHighWaterSequence = overlayHighWaterSequence;
 104        PhysicalVersion = physicalVersion;
 105        ComponentId = componentId;
 106        ComponentVersion = componentVersion;
 107        IncidentExplicitEdgeCount = incidentExplicitEdgeCount;
 108        IsMaterialized = isMaterialized;
 109        WorldSpawnToken = worldSpawnToken;
 110        GridSpawnToken = gridSpawnToken;
 111        ConfigurationKey = configurationKey;
 112        TopologyKind = topologyKind;
 113        StorageKind = storageKind;
 114        LookupKind = lookupKind;
 115        BakedSlotCount = bakedSlotCount;
 116        DynamicSlotCount = dynamicSlotCount;
 117        RetainedBytes = retainedBytes;
 118        LastBaselineAddressCount = lastBaselineAddressCount;
 119        LastCopiedSemanticPages = lastCopiedSemanticPages;
 120        LastCopiedPhysicalPages = lastCopiedPhysicalPages;
 121        _cells = System.Array.AsReadOnly(cells);
 122    }
 123
 124    /// <summary>Gets the stable map ID.</summary>
 125    public string MapId { get; }
 126    /// <summary>Gets the immutable bake version.</summary>
 127    public long BakeVersion { get; }
 128    /// <summary>Gets the last graph generation that changed this instance.</summary>
 129    public long InstanceVersion { get; }
 130    /// <summary>Gets the semantic overlay high-water sequence.</summary>
 131    public long OverlayHighWaterSequence { get; }
 132    /// <summary>Gets the last immutable physical-page publication version.</summary>
 133    public long PhysicalVersion { get; }
 134    /// <summary>Gets the deterministic weak structural component ID.</summary>
 135    public int ComponentId { get; }
 136    /// <summary>Gets the component/composition generation.</summary>
 137    public long ComponentVersion { get; }
 138    /// <summary>Gets the source and incoming explicit dependency count.</summary>
 139    public int IncidentExplicitEdgeCount { get; }
 140    /// <summary>Gets whether an exact GridForge generation is active.</summary>
 141    public bool IsMaterialized { get; }
 142    /// <summary>Gets the exact owning GridWorld generation.</summary>
 143    public long WorldSpawnToken { get; }
 144    /// <summary>Gets the exact runtime grid generation.</summary>
 145    public long GridSpawnToken { get; }
 146    /// <summary>Gets the normalized authored grid address.</summary>
 147    public GridConfigurationKey ConfigurationKey { get; }
 148    /// <summary>Gets the topology kind.</summary>
 149    public GridTopologyKind TopologyKind { get; }
 150    /// <summary>Gets the storage kind of the normalized binding.</summary>
 151    public GridStorageKind StorageKind { get; }
 152    /// <summary>Gets the density-selected local lookup representation.</summary>
 153    public NavigationCellLookupKind LookupKind { get; }
 154    /// <summary>Gets the stable baked slot count.</summary>
 155    public int BakedSlotCount { get; }
 156    /// <summary>Gets the non-reused dynamic slot count.</summary>
 157    public int DynamicSlotCount { get; }
 158    /// <summary>Gets conservative retained instance bytes.</summary>
 159    public long RetainedBytes { get; }
 160    /// <summary>Gets the addresses read by this instance's latest baseline capture.</summary>
 161    public int LastBaselineAddressCount { get; }
 162    /// <summary>Gets the semantic leaf pages copied by this instance's latest update.</summary>
 163    public int LastCopiedSemanticPages { get; }
 164    /// <summary>Gets the physical leaf pages copied by this instance's latest update.</summary>
 165    public int LastCopiedPhysicalPages { get; }
 166    /// <summary>Gets copied addressed cell diagnostics.</summary>
 167    public IReadOnlyList<NavigationGraphCellDiagnostic> Cells => _cells;
 168}
 169
 170/// <summary>Copies a bounded immutable navigation graph diagnostic view.</summary>
 171public sealed class NavigationGraphDiagnosticsSnapshot
 172{
 173    private readonly ReadOnlyCollection<NavigationGraphMapDiagnostic> _maps;
 174
 175    internal NavigationGraphDiagnosticsSnapshot(
 176        long graphVersion,
 177        long areaCatalogVersion,
 178        long activeSnapshotBytes,
 179        int activeSnapshotCount,
 180        int activeSnapshotLeaseCount,
 181        int persistentGraphPageCount,
 182        int retiredGenerationCount,
 183        long retiredSnapshotBytes,
 184        int pendingAreaPolicyCount,
 185        int pendingAreaRuleCount,
 186        long pendingAreaPolicyBytes,
 187        int baselineRebuildCount,
 188        int baselineCapacityBlockedCount,
 189        long baselineRebuildBytes,
 190        int baselineRebuildPageCount,
 191        bool isTruncated,
 192        NavigationGraphMapDiagnostic[] maps)
 193    {
 194        GraphVersion = graphVersion;
 195        AreaCatalogVersion = areaCatalogVersion;
 196        ActiveSnapshotBytes = activeSnapshotBytes;
 197        ActiveSnapshotCount = activeSnapshotCount;
 198        ActiveSnapshotLeaseCount = activeSnapshotLeaseCount;
 199        PersistentGraphPageCount = persistentGraphPageCount;
 200        RetiredGenerationCount = retiredGenerationCount;
 201        RetiredSnapshotBytes = retiredSnapshotBytes;
 202        PendingAreaPolicyCount = pendingAreaPolicyCount;
 203        PendingAreaRuleCount = pendingAreaRuleCount;
 204        PendingAreaPolicyBytes = pendingAreaPolicyBytes;
 205        BaselineRebuildCount = baselineRebuildCount;
 206        BaselineCapacityBlockedCount = baselineCapacityBlockedCount;
 207        BaselineRebuildBytes = baselineRebuildBytes;
 208        BaselineRebuildPageCount = baselineRebuildPageCount;
 209        IsTruncated = isTruncated;
 210        _maps = System.Array.AsReadOnly(maps);
 211    }
 212
 213    /// <summary>Gets the immutable graph generation.</summary>
 214    public long GraphVersion { get; }
 215    /// <summary>Gets the immutable area-catalog generation.</summary>
 216    public long AreaCatalogVersion { get; }
 217    /// <summary>Gets conservative current-root plus unpublished retained-work bytes.</summary>
 218    public long ActiveSnapshotBytes { get; }
 219    /// <summary>Gets the current plus leased retired snapshot-generation count.</summary>
 220    public int ActiveSnapshotCount { get; }
 221    /// <summary>Gets the number of checked-out snapshot leases.</summary>
 222    public int ActiveSnapshotLeaseCount { get; }
 223    /// <summary>Gets conservative current-root plus unpublished retained-work page count.</summary>
 224    public int PersistentGraphPageCount { get; }
 225    /// <summary>Gets leased retired generation count.</summary>
 226    public int RetiredGenerationCount { get; }
 227    /// <summary>Gets conservative leased retired-root bytes.</summary>
 228    public long RetiredSnapshotBytes { get; }
 229    /// <summary>Gets the number of admitted area-policy revisions awaiting terminal publication.</summary>
 230    public int PendingAreaPolicyCount { get; }
 231    /// <summary>Gets direct-indexed rules retained by pending area-policy revisions.</summary>
 232    public int PendingAreaRuleCount { get; }
 233    /// <summary>Gets conservative bytes retained by pending area-policy revisions.</summary>
 234    public long PendingAreaPolicyBytes { get; }
 235    /// <summary>Gets the number of fail-closed map baselines being rebuilt across frames.</summary>
 236    public int BaselineRebuildCount { get; }
 237    /// <summary>Gets terminal fail-closed baselines whose configured active cap cannot fit another page.</summary>
 238    public int BaselineCapacityBlockedCount { get; }
 239    /// <summary>Gets conservatively retained unpublished baseline-rebuild bytes.</summary>
 240    public long BaselineRebuildBytes { get; }
 241    /// <summary>Gets conservatively retained unpublished baseline-rebuild pages.</summary>
 242    public int BaselineRebuildPageCount { get; }
 243    /// <summary>Gets whether the context diagnostic cell ceiling truncated output.</summary>
 244    public bool IsTruncated { get; }
 245    /// <summary>Gets map diagnostics in ordinal MapId order.</summary>
 246    public IReadOnlyList<NavigationGraphMapDiagnostic> Maps => _maps;
 247}