< Summary

Information
Class: Trailblazer.Pathing.NavigationAreaRule
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Traversal/NavigationAreaRule.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 56
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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_IsAllowed()100%11100%
Equals(...)100%22100%
Equals(...)100%22100%
GetHashCode()100%11100%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/Traversal/NavigationAreaRule.cs

#LineLine coverage
 1//=======================================================================
 2// NavigationAreaRule.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;
 10using SwiftCollections.Utility;
 11
 12namespace Trailblazer.Pathing;
 13
 14/// <summary>
 15/// Defines one immutable query-specific admission and enter-cost rule.
 16/// </summary>
 17public readonly struct NavigationAreaRule : IEquatable<NavigationAreaRule>
 18{
 19    private readonly bool _isDenied;
 20
 21    /// <summary>Creates an immutable navigation-area rule.</summary>
 22    public NavigationAreaRule(bool isAllowed, Fixed64 additionalEnterCost)
 23    {
 73324        SwiftThrowHelper.ThrowIfArgumentOutOfRange(
 73325            additionalEnterCost < Fixed64.Zero,
 73326            actualValue: null,
 73327            nameof(additionalEnterCost),
 73328            "Additional enter cost must be non-negative.");
 29
 73230        _isDenied = !isAllowed;
 73231        AdditionalEnterCost = additionalEnterCost;
 73232    }
 33
 34    /// <summary>Gets whether the query may enter this area.</summary>
 22845635    public bool IsAllowed => !_isDenied;
 36
 37    /// <summary>Gets the non-negative query-specific enter-cost surcharge.</summary>
 38    public Fixed64 AdditionalEnterCost { get; }
 39
 40    /// <inheritdoc/>
 41    public bool Equals(NavigationAreaRule other) =>
 1642        _isDenied == other._isDenied && AdditionalEnterCost == other.AdditionalEnterCost;
 43
 44    /// <inheritdoc/>
 245    public override bool Equals(object? obj) => obj is NavigationAreaRule other && Equals(other);
 46
 47    /// <inheritdoc/>
 48    public override int GetHashCode() =>
 249        SwiftHashTools.CombineHashCodes(_isDenied ? 1 : 0, AdditionalEnterCost.GetHashCode());
 50
 51    /// <summary>Tests two rules for equality.</summary>
 152    public static bool operator ==(NavigationAreaRule left, NavigationAreaRule right) => left.Equals(right);
 53
 54    /// <summary>Tests two rules for inequality.</summary>
 155    public static bool operator !=(NavigationAreaRule left, NavigationAreaRule right) => !left.Equals(right);
 56}