< Summary

Information
Class: Trailblazer.Navigation.TrailblazerNavigationService
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/TrailblazerNavigationService.cs
Line coverage
100%
Covered lines: 18
Uncovered lines: 0
Coverable lines: 18
Total lines: 57
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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_Context()100%11100%
Bind(...)100%11100%
CreateNavigatorId()100%11100%
Reset()100%11100%
EnsureUsable()100%22100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/TrailblazerNavigationService.cs

#LineLine coverage
 1using SwiftCollections;
 2using System;
 3using Trailblazer.Navigation.MovementGroups;
 4
 5namespace Trailblazer.Navigation;
 6
 7/// <summary>
 8/// Context-owned navigation coordination state for navigators, steering, movement groups, and ids.
 9/// </summary>
 10public sealed class TrailblazerNavigationService
 11{
 12    private readonly TrailblazerWorldContext _context;
 13
 96114    internal TrailblazerNavigationService(TrailblazerWorldContext context)
 15    {
 96116        _context = context;
 96117        MovementGroups = new MovementGroupCoordinatorState(context);
 96118        NavigatorIds = new NavigatorGlobalIdAllocatorState();
 96119    }
 20
 21    /// <summary>
 22    /// Gets the world context that owns this navigation service.
 23    /// </summary>
 124    public TrailblazerWorldContext Context => _context;
 25
 26    internal MovementGroupCoordinatorState MovementGroups { get; }
 27
 28    internal NavigatorGlobalIdAllocatorState NavigatorIds { get; }
 29
 30    /// <summary>
 31    /// Binds an uninitialized navigator to this context.
 32    /// </summary>
 33    public void Bind(Navigator navigator)
 34    {
 235        SwiftThrowHelper.ThrowIfNull(navigator, nameof(navigator));
 136        navigator.BindContext(_context);
 137    }
 38
 39    internal Guid CreateNavigatorId()
 40    {
 15641        EnsureUsable();
 15442        return NavigatorIds.Create();
 43    }
 44
 45    internal void Reset()
 46    {
 2547        MovementGroups.Reset();
 2548        NavigatorIds.Reset();
 2549    }
 50
 51    private void EnsureUsable()
 52    {
 15653        SwiftThrowHelper.ThrowIfDisposed(_context.IsDisposed, nameof(TrailblazerWorldContext));
 15554        if (!_context.World.IsActive)
 155            throw new InvalidOperationException("TrailblazerNavigationService is bound to an inactive GridWorld.");
 15456    }
 57}