< Summary

Information
Class: Trailblazer.Pathing.NavigationGraphMapDiagnostic
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/NavigationGraphDiagnosticsSnapshot.cs
Line coverage
100%
Covered lines: 47
Uncovered lines: 0
Coverable lines: 47
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_Cells()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    {
 44        Index = index;
 45        Slot = slot;
 46        SemanticSource = semanticSource;
 47        HasCell = hasCell;
 48        Cell = cell;
 49        IsPresent = isPresent;
 50        ObstacleCount = obstacleCount;
 51    }
 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>
 68    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
 1463576    internal NavigationGraphMapDiagnostic(
 1463577        string mapId,
 1463578        long bakeVersion,
 1463579        long instanceVersion,
 1463580        long overlayHighWaterSequence,
 1463581        long physicalVersion,
 1463582        int componentId,
 1463583        long componentVersion,
 1463584        int incidentExplicitEdgeCount,
 1463585        bool isMaterialized,
 1463586        long worldSpawnToken,
 1463587        long gridSpawnToken,
 1463588        GridConfigurationKey configurationKey,
 1463589        GridTopologyKind topologyKind,
 1463590        GridStorageKind storageKind,
 1463591        NavigationCellLookupKind lookupKind,
 1463592        int bakedSlotCount,
 1463593        int dynamicSlotCount,
 1463594        long retainedBytes,
 1463595        int lastBaselineAddressCount,
 1463596        int lastCopiedSemanticPages,
 1463597        int lastCopiedPhysicalPages,
 1463598        NavigationGraphCellDiagnostic[] cells)
 99    {
 14635100        MapId = mapId;
 14635101        BakeVersion = bakeVersion;
 14635102        InstanceVersion = instanceVersion;
 14635103        OverlayHighWaterSequence = overlayHighWaterSequence;
 14635104        PhysicalVersion = physicalVersion;
 14635105        ComponentId = componentId;
 14635106        ComponentVersion = componentVersion;
 14635107        IncidentExplicitEdgeCount = incidentExplicitEdgeCount;
 14635108        IsMaterialized = isMaterialized;
 14635109        WorldSpawnToken = worldSpawnToken;
 14635110        GridSpawnToken = gridSpawnToken;
 14635111        ConfigurationKey = configurationKey;
 14635112        TopologyKind = topologyKind;
 14635113        StorageKind = storageKind;
 14635114        LookupKind = lookupKind;
 14635115        BakedSlotCount = bakedSlotCount;
 14635116        DynamicSlotCount = dynamicSlotCount;
 14635117        RetainedBytes = retainedBytes;
 14635118        LastBaselineAddressCount = lastBaselineAddressCount;
 14635119        LastCopiedSemanticPages = lastCopiedSemanticPages;
 14635120        LastCopiedPhysicalPages = lastCopiedPhysicalPages;
 14635121        _cells = System.Array.AsReadOnly(cells);
 14635122    }
 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>
 14644167    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}