< Summary

Information
Class: Trailblazer.Pathing.TrailblazerVolumeRulesService
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/VolumeRules/TrailblazerVolumeRulesService.cs
Line coverage
100%
Covered lines: 53
Uncovered lines: 0
Coverable lines: 53
Total lines: 124
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_HasGasVoxelRule()100%11100%
get_HasLiquidVoxelRule()100%11100%
get_RegistryVersion()100%11100%
SetGasVoxelPartition()100%11100%
SetGasVoxelRule(...)100%11100%
ClearGasVoxelRule()100%11100%
SetLiquidVoxelPartition()100%11100%
SetLiquidVoxelRule(...)100%11100%
ClearLiquidVoxelRule()100%11100%
IsConfigured(...)100%11100%
Matches(...)100%11100%
EnsureUsable()100%44100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Pathing/VolumeRules/TrailblazerVolumeRulesService.cs

#LineLine coverage
 1using GridForge.Grids;
 2using GridForge.Spatial;
 3using System;
 4
 5namespace Trailblazer.Pathing;
 6
 7/// <summary>
 8/// Context-owned API for host-configured raw-volume medium rules.
 9/// </summary>
 10public sealed class TrailblazerVolumeRulesService
 11{
 12    private readonly TrailblazerWorldContext _context;
 13    private readonly PathingWorldState _state;
 14
 96115    internal TrailblazerVolumeRulesService(TrailblazerWorldContext context, PathingWorldState state)
 16    {
 96117        _context = context;
 96118        _state = state;
 96119    }
 20
 21    /// <inheritdoc cref="VolumeMediumRules.HasGasVoxelRule"/>
 22    public bool HasGasVoxelRule
 23    {
 24        get
 25        {
 926            EnsureUsable();
 727            using (PathManager.EnterState(_state))
 728                return VolumeMediumRules.HasGasVoxelRule;
 729        }
 30    }
 31
 32    /// <inheritdoc cref="VolumeMediumRules.HasLiquidVoxelRule"/>
 33    public bool HasLiquidVoxelRule
 34    {
 35        get
 36        {
 437            EnsureUsable();
 438            using (PathManager.EnterState(_state))
 439                return VolumeMediumRules.HasLiquidVoxelRule;
 440        }
 41    }
 42
 43    internal int RegistryVersion
 44    {
 45        get
 46        {
 247            EnsureUsable();
 248            using (PathManager.EnterState(_state))
 249                return VolumeMediumRules.RegistryVersion;
 250        }
 51    }
 52
 53    /// <inheritdoc cref="VolumeMediumRules.SetGasVoxelPartition{TPartition}"/>
 54    public void SetGasVoxelPartition<TPartition>()
 55        where TPartition : class, IVoxelPartition
 56    {
 157        EnsureUsable();
 158        using (PathManager.EnterState(_state))
 159            VolumeMediumRules.SetGasVoxelPartition<TPartition>();
 160    }
 61
 62    /// <inheritdoc cref="VolumeMediumRules.SetGasVoxelRule(VolumeVoxelRule)"/>
 63    public void SetGasVoxelRule(VolumeVoxelRule rule)
 64    {
 365        EnsureUsable();
 366        using (PathManager.EnterState(_state))
 367            VolumeMediumRules.SetGasVoxelRule(rule);
 368    }
 69
 70    /// <inheritdoc cref="VolumeMediumRules.ClearGasVoxelRule"/>
 71    public void ClearGasVoxelRule()
 72    {
 173        EnsureUsable();
 174        using (PathManager.EnterState(_state))
 175            VolumeMediumRules.ClearGasVoxelRule();
 176    }
 77
 78    /// <inheritdoc cref="VolumeMediumRules.SetLiquidVoxelPartition{TPartition}"/>
 79    public void SetLiquidVoxelPartition<TPartition>()
 80        where TPartition : class, IVoxelPartition
 81    {
 182        EnsureUsable();
 183        using (PathManager.EnterState(_state))
 184            VolumeMediumRules.SetLiquidVoxelPartition<TPartition>();
 185    }
 86
 87    /// <inheritdoc cref="VolumeMediumRules.SetLiquidVoxelRule(VolumeVoxelRule)"/>
 88    public void SetLiquidVoxelRule(VolumeVoxelRule rule)
 89    {
 190        EnsureUsable();
 191        using (PathManager.EnterState(_state))
 192            VolumeMediumRules.SetLiquidVoxelRule(rule);
 193    }
 94
 95    /// <inheritdoc cref="VolumeMediumRules.ClearLiquidVoxelRule"/>
 96    public void ClearLiquidVoxelRule()
 97    {
 198        EnsureUsable();
 199        using (PathManager.EnterState(_state))
 1100            VolumeMediumRules.ClearLiquidVoxelRule();
 1101    }
 102
 103    internal bool IsConfigured(TraversalMedium medium)
 104    {
 3105        EnsureUsable();
 3106        using (PathManager.EnterState(_state))
 3107            return VolumeMediumRules.IsConfigured(medium);
 3108    }
 109
 110    internal bool Matches(Voxel voxel, TraversalMedium medium)
 111    {
 4112        EnsureUsable();
 4113        using (PathManager.EnterState(_state))
 4114            return VolumeMediumRules.Matches(voxel, medium);
 4115    }
 116
 117    private void EnsureUsable()
 118    {
 30119        if (_context.IsDisposed)
 1120            throw new ObjectDisposedException(nameof(TrailblazerWorldContext));
 29121        if (!_context.World.IsActive)
 1122            throw new InvalidOperationException("TrailblazerVolumeRulesService is bound to an inactive GridWorld.");
 28123    }
 124}