< Summary

Information
Class: Trailblazer.Pathing.NavigationTokenLegendEntry
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Map/NavigationTokenLegendEntry.cs
Line coverage
100%
Covered lines: 26
Uncovered lines: 0
Coverable lines: 26
Total lines: 89
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
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%22100%
SkipCell()100%11100%
CreateCell(...)100%44100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Map/NavigationTokenLegendEntry.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationTokenLegendEntry.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;
 9using FixedMathSharp;
 10
 11namespace Trailblazer.Pathing;
 12
 13/// <summary>
 14/// Describes the complete navigation payload and optional transition marker media for one token.
 15/// </summary>
 16public readonly struct NavigationTokenLegendEntry
 17{
 18    /// <summary>
 19    /// Whether this entry emits an authored navigation cell.
 20    /// </summary>
 21    public bool EmitsCell { get; }
 22
 23    /// <summary>
 24    /// The complete cell payload emitted when <see cref="EmitsCell"/> is true.
 25    /// </summary>
 26    public NavigationCell Cell { get; }
 27
 28    /// <summary>
 29    /// The subset of authored media exposed when the token carries a trailing marker.
 30    /// </summary>
 31    public TraversalMedia TransitionMedia { get; }
 32
 33    /// <summary>
 34    /// Creates an entry that emits a complete cell payload.
 35    /// </summary>
 36    public NavigationTokenLegendEntry(
 37        NavigationCell cell,
 38        TraversalMedia transitionMedia = TraversalMedia.None)
 39    {
 16940        SwiftThrowHelper.ThrowIfArgument(
 16941            cell.Media == TraversalMedia.None,
 16942            nameof(cell),
 16943            "The emitted cell must contain at least one known traversal-medium bit.");
 44
 45        System.Diagnostics.Debug.Assert((cell.Media & ~NavigationCell.KnownMedia) == 0);
 46        System.Diagnostics.Debug.Assert((cell.RequiredCapabilities & ~NavigationCell.KnownCapabilities) == 0);
 47        System.Diagnostics.Debug.Assert((cell.Flags & ~NavigationCell.KnownFlags) == 0);
 48        System.Diagnostics.Debug.Assert(cell.EnterCost >= Fixed64.Zero);
 49        System.Diagnostics.Debug.Assert(cell.RadiusClearance >= Fixed64.Zero);
 50        System.Diagnostics.Debug.Assert(cell.HeightClearance >= Fixed64.Zero);
 51
 16852        SwiftThrowHelper.ThrowIfArgument(
 16853            (transitionMedia & ~NavigationCell.KnownMedia) != 0
 16854            || (transitionMedia & ~cell.Media) != 0,
 16855            nameof(transitionMedia),
 16856            "Transition media must be a known subset of the emitted cell media.");
 57
 16658        EmitsCell = true;
 16659        Cell = cell;
 16660        TransitionMedia = transitionMedia;
 16661    }
 62
 63    /// <summary>
 64    /// Creates an entry that emits no cell or transition metadata.
 65    /// </summary>
 6766    public static NavigationTokenLegendEntry SkipCell() => default;
 67
 68    internal NavigationCell CreateCell(
 69        Fixed64 inlineCost,
 70        bool hasInlineCost,
 71        bool hasTransitionMarker)
 72    {
 3573        NavigationCellFlags flags = Cell.Flags;
 3574        if (hasTransitionMarker)
 75        {
 2476            flags |= NavigationCellFlags.TransitionSourceHint
 2477                | NavigationCellFlags.TransitionDestinationHint;
 78        }
 79
 3580        return new NavigationCell(
 3581            Cell.Media,
 3582            Cell.RequiredCapabilities,
 3583            Cell.Area,
 3584            hasInlineCost ? inlineCost : Cell.EnterCost,
 3585            Cell.RadiusClearance,
 3586            Cell.HeightClearance,
 3587            flags);
 88    }
 89}