< Summary

Information
Class: Trailblazer.Pathing.NavigationCellAddress
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Map/NavigationCellAddress.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 84
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%11100%
CompareTo(...)100%22100%
Equals(...)100%22100%
Equals(...)100%22100%
GetHashCode()100%22100%
ToString()100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// NavigationCellAddress.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 GridForge.Spatial;
 10using SwiftCollections.Utility;
 11
 12namespace Trailblazer.Pathing;
 13
 14/// <summary>
 15/// Identifies one durable navigation cell by ordinal map ID and topology-local index.
 16/// </summary>
 17public readonly struct NavigationCellAddress :
 18    IEquatable<NavigationCellAddress>,
 19    IComparable<NavigationCellAddress>
 20{
 21    /// <summary>
 22    /// The stable host-owned map identifier.
 23    /// </summary>
 24    public string MapId { get; }
 25
 26    /// <summary>
 27    /// The topology-local X/Q, Y/layer, Z/R cell index.
 28    /// </summary>
 29    public VoxelIndex Index { get; }
 30
 31    /// <summary>
 32    /// Creates a durable cell address.
 33    /// </summary>
 34    public NavigationCellAddress(string mapId, VoxelIndex index)
 35    {
 566184036        SwiftThrowHelper.ThrowIfArgument(
 566184037            string.IsNullOrWhiteSpace(mapId),
 566184038            nameof(mapId),
 566184039            "Map ID cannot be null, empty, or whitespace.");
 40
 566184041        MapId = mapId;
 566184042        Index = index;
 566184043    }
 44
 45    /// <inheritdoc/>
 46    public int CompareTo(NavigationCellAddress other)
 47    {
 99334048        int result = StringComparer.Ordinal.Compare(MapId, other.MapId);
 99334049        return result != 0 ? result : Index.CompareTo(other.Index);
 50    }
 51
 52    /// <inheritdoc/>
 53    public bool Equals(NavigationCellAddress other) =>
 283951854        string.Equals(MapId, other.MapId, StringComparison.Ordinal)
 283951855        && Index.Equals(other.Index);
 56
 57    /// <inheritdoc/>
 58    public override bool Equals(object? obj) =>
 57259        obj is NavigationCellAddress other && Equals(other);
 60
 61    /// <inheritdoc/>
 62    public override int GetHashCode()
 63    {
 50413064        int mapHash = MapId == null
 50413065            ? 0
 50413066            : SwiftHashTools.GetDeterministicStringEqualityComparer().GetHashCode(MapId);
 50413067        return SwiftHashTools.CombineHashCodes(mapHash, Index.GetHashCode());
 68    }
 69
 70    /// <inheritdoc/>
 271    public override string ToString() => $"{MapId}:{Index}";
 72
 73    /// <summary>
 74    /// Tests two addresses for value equality.
 75    /// </summary>
 76    public static bool operator ==(NavigationCellAddress left, NavigationCellAddress right) =>
 658677        left.Equals(right);
 78
 79    /// <summary>
 80    /// Tests two addresses for value inequality.
 81    /// </summary>
 82    public static bool operator !=(NavigationCellAddress left, NavigationCellAddress right) =>
 243783        !left.Equals(right);
 84}