< Summary

Information
Class: Trailblazer.Navigation.NavigatorOccupancyTracker
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Navigator/Occupancy/NavigatorOccupancyTracker.cs
Line coverage
94%
Covered lines: 32
Uncovered lines: 2
Coverable lines: 34
Total lines: 66
Line coverage: 94.1%
Branch coverage
69%
Covered branches: 18
Total branches: 26
Branch coverage: 69.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Update(...)85.71%1414100%
UpdateAfterRootProjection(...)50%121286.66%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Navigator/Occupancy/NavigatorOccupancyTracker.cs

#LineLine coverage
 1using FixedMathSharp;
 2using GridForge.Grids;
 3
 4namespace Trailblazer.Navigation;
 5
 6internal static class NavigatorOccupancyTracker
 7{
 8    public static void Update(
 9        GridWorld world,
 10        Navigator navigator,
 11        Vector3d position,
 12        Vector3d lastPosition,
 13        bool init)
 14    {
 19215        if (!init && position == lastPosition)
 116            return;
 17
 19118        bool voxelFound = world.TryGetGridAndVoxel(
 19119            position,
 19120            out VoxelGrid? curGrid,
 19121            out Voxel? curVoxel);
 19122        if (!voxelFound)
 223            return;
 24
 18925        if (curGrid!.TryAddVoxelOccupant(curVoxel!, navigator) == false)
 26        {
 5227            TrailblazerLogger.Channel.Warn($"Navigator {navigator.GlobalId} failed to register occupancy in voxel {curVo
 5228            return;
 29        }
 30
 13731        bool lastVoxelFound = world.TryGetGridAndVoxel(
 13732            lastPosition,
 13733            out VoxelGrid? lastGrid,
 13734            out Voxel? lastVoxel);
 35
 13736        if (!lastVoxelFound || curVoxel == lastVoxel)
 13337            return;
 38
 439        lastGrid!.TryRemoveVoxelOccupant(lastVoxel!, navigator);
 440    }
 41
 42    public static void UpdateAfterRootProjection(
 43        GridWorld world,
 44        Navigator navigator,
 45        Vector3d oldPosition,
 46        Vector3d newPosition)
 47    {
 248        bool oldVoxelFound = world.TryGetGridAndVoxel(
 249            oldPosition,
 250            out VoxelGrid? oldGrid,
 251            out Voxel? oldVoxel);
 252        bool newVoxelFound = world.TryGetGridAndVoxel(
 253            newPosition,
 254            out VoxelGrid? newGrid,
 255            out Voxel? newVoxel);
 56
 257        if (oldVoxelFound && newVoxelFound && oldVoxel == newVoxel)
 058            return;
 59
 260        if (oldVoxelFound)
 261            oldGrid!.TryRemoveVoxelOccupant(oldVoxel!, navigator);
 62
 263        if (newVoxelFound && newGrid!.TryAddVoxelOccupant(newVoxel!, navigator) == false)
 064            TrailblazerLogger.Channel.Warn($"Navigator {navigator.GlobalId} failed to register occupancy in voxel {newVo
 265    }
 66}