< Summary

Information
Class: GridForge.Blockers.BoundsBlocker
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Blockers/BoundsBlocker.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 73
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%
CreateBlockArea(...)100%11100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// BoundsBlocker.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.Bounds;
 10using GridForge.Grids;
 11using GridForge.Spatial;
 12
 13namespace GridForge.Blockers;
 14
 15/// <summary>
 16/// A manually placed blocker that obstructs a defined bounding area.
 17/// </summary>
 18public class BoundsBlocker : Blocker
 19{
 20    private FixedBoundArea _blockArea;
 21
 22    /// <summary>
 23    /// Initializes a new bounds blocker bound to the supplied world.
 24    /// </summary>
 25    /// <param name="world">The world whose grids this blocker should affect.</param>
 26    /// <param name="blockArea">The bounding area to block.</param>
 27    /// <param name="isActive">Flag whether or not blocker is active.</param>
 28    /// <param name="cacheCoveredVoxels">Flag whether or not to cache covered voxels.</param>
 29    public BoundsBlocker(
 30        GridWorld world,
 31        FixedBoundArea blockArea,
 32        bool isActive = true,
 14833        bool cacheCoveredVoxels = false) : base(world, isActive, cacheCoveredVoxels)
 34    {
 14835        _blockArea = blockArea;
 14836    }
 37
 38    /// <summary>
 39    /// Initializes a new bounds blocker from XZ-plane bounds on the supplied world Y layer.
 40    /// </summary>
 41    /// <param name="world">The world whose grids this blocker should affect.</param>
 42    /// <param name="boundsMin">The 2D minimum bound whose X component maps to world X and Y component maps to world Z.<
 43    /// <param name="boundsMax">The 2D maximum bound whose X component maps to world X and Y component maps to world Z.<
 44    /// <param name="layerY">The world Y layer to block. Defaults to zero.</param>
 45    /// <param name="isActive">Flag whether or not blocker is active.</param>
 46    /// <param name="cacheCoveredVoxels">Flag whether or not to cache covered voxels.</param>
 47    public BoundsBlocker(
 48        GridWorld world,
 49        Vector2d boundsMin,
 50        Vector2d boundsMax,
 51        Fixed64 layerY = default,
 52        bool isActive = true,
 53        bool cacheCoveredVoxels = false)
 554        : this(
 555            world,
 556            CreateBlockArea(boundsMin, boundsMax, layerY),
 557            isActive,
 558            cacheCoveredVoxels)
 59    {
 560    }
 61
 62    /// <inheritdoc cref="Blocker.GetBoundsMin"/>
 15463    protected override Vector3d GetBoundsMin() => _blockArea.Min;
 64
 65    /// <inheritdoc cref="Blocker.GetBoundsMax"/>
 15466    protected override Vector3d GetBoundsMax() => _blockArea.Max;
 67
 68    private static FixedBoundArea CreateBlockArea(Vector2d boundsMin, Vector2d boundsMax, Fixed64 layerY)
 69    {
 570        (Vector3d min, Vector3d max) = GridPlane2d.ToWorldBounds(boundsMin, boundsMax, layerY);
 571        return new FixedBoundArea(min, max);
 72    }
 73}