< Summary

Information
Class: GridForge.Blockers.AreaBlocker
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Blockers/AreaBlocker.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 71
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
.ctor(...)100%11100%
GetBoundsMin()100%11100%
GetBoundsMax()100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Blockers/AreaBlocker.cs

#LineLine coverage
 1//=======================================================================
 2// AreaBlocker.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 FixedMathSharp;
 9using FixedMathSharp.Geometry;
 10using GridForge.Grids;
 11using GridForge.Spatial;
 12
 13namespace GridForge.Blockers;
 14
 15/// <summary>
 16/// A manually placed blocker that obstructs a two-dimensional XZ-plane area on one world Y layer.
 17/// </summary>
 18public class AreaBlocker : Blocker
 19{
 20    private readonly FixedBoundArea _blockArea;
 21    private readonly Fixed64 _layerY;
 22
 23    /// <summary>
 24    /// Initializes a new area blocker bound to the supplied world.
 25    /// </summary>
 26    /// <param name="world">The world whose grids this blocker should affect.</param>
 27    /// <param name="blockArea">The XZ-plane area to block.</param>
 28    /// <param name="layerY">The world Y layer to block. Defaults to zero.</param>
 29    /// <param name="isActive">Flag whether or not blocker is active.</param>
 30    /// <param name="cacheCoveredVoxels">Flag whether or not to cache covered voxels.</param>
 31    public AreaBlocker(
 32        GridWorld world,
 33        FixedBoundArea blockArea,
 34        Fixed64 layerY = default,
 35        bool isActive = true,
 236        bool cacheCoveredVoxels = false) : base(world, isActive, cacheCoveredVoxels)
 37    {
 238        _blockArea = blockArea;
 239        _layerY = layerY;
 240    }
 41
 42    /// <summary>
 43    /// Initializes a new area blocker from XZ-plane min/max bounds.
 44    /// </summary>
 45    /// <param name="world">The world whose grids this blocker should affect.</param>
 46    /// <param name="boundsMin">The 2D minimum bound whose X component maps to world X and Y component maps to world Z.<
 47    /// <param name="boundsMax">The 2D maximum bound whose X component maps to world X and Y component maps to world Z.<
 48    /// <param name="layerY">The world Y layer to block. Defaults to zero.</param>
 49    /// <param name="isActive">Flag whether or not blocker is active.</param>
 50    /// <param name="cacheCoveredVoxels">Flag whether or not to cache covered voxels.</param>
 51    public AreaBlocker(
 52        GridWorld world,
 53        Vector2d boundsMin,
 54        Vector2d boundsMax,
 55        Fixed64 layerY = default,
 56        bool isActive = true,
 57        bool cacheCoveredVoxels = false)
 158        : this(
 159            world,
 160            FixedBoundArea.FromMinMax(boundsMin, boundsMax),
 161            layerY,
 162            isActive,
 163            cacheCoveredVoxels)
 164    { }
 65
 66    /// <inheritdoc cref="Blocker.GetBoundsMin"/>
 467    protected override Vector3d GetBoundsMin() => GridPlane2d.ToWorld(_blockArea.Min, _layerY);
 68
 69    /// <inheritdoc cref="Blocker.GetBoundsMax"/>
 470    protected override Vector3d GetBoundsMax() => GridPlane2d.ToWorld(_blockArea.Max, _layerY);
 71}