< Summary

Information
Class: Trailblazer.Pathing.NavigationMediumStateRef
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Graph/NavigationMediumStateRef.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 49
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
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%11100%
get_IsValid()100%22100%
CompareTo(...)100%66100%
Equals(...)100%22100%
GetHashCode()100%11100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// NavigationMediumStateRef.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 SwiftCollections.Utility;
 10
 11namespace Trailblazer.Pathing;
 12
 13/// <summary>Identifies one traversal-medium state over an immutable physical node.</summary>
 14internal readonly struct NavigationMediumStateRef :
 15    IEquatable<NavigationMediumStateRef>,
 16    IComparable<NavigationMediumStateRef>
 17{
 18    internal NavigationMediumStateRef(NavigationNodeRef node, TraversalMedium medium)
 19    {
 35313320        Node = node;
 35313321        Medium = medium;
 35313322    }
 23
 24    internal NavigationNodeRef Node { get; }
 25
 26    internal TraversalMedium Medium { get; }
 27
 1228    internal bool IsValid => Node.IsValid && NavigationCell.IsKnownMedium(Medium);
 29
 30    public int CompareTo(NavigationMediumStateRef other)
 31    {
 632        int comparison = Node.MapOrdinal.CompareTo(other.Node.MapOrdinal);
 633        if (comparison != 0)
 134            return comparison;
 535        comparison = Node.CellSlot.CompareTo(other.Node.CellSlot);
 536        if (comparison != 0)
 137            return comparison;
 438        int medium = (int)Medium;
 439        int otherMedium = (int)other.Medium;
 440        return medium < otherMedium ? -1 : medium > otherMedium ? 1 : 0;
 41    }
 42
 43    public bool Equals(NavigationMediumStateRef other) =>
 8729644        Node.Equals(other.Node) && Medium == other.Medium;
 45
 46    public override int GetHashCode() =>
 8317047        SwiftHashTools.CombineHashCodes(Node.GetHashCode(), (int)Medium);
 48
 49}