< Summary

Information
Class: GridForge.Grids.GridEventInfo
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/GridEventInfo.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 107
Line coverage: 100%
Branch coverage
100%
Covered branches: 12
Total branches: 12
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_BoundsMin()100%11100%
get_BoundsMax()100%11100%
.ctor(...)100%1212100%
ToBoundsKey()100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/GridEventInfo.cs

#LineLine coverage
 1//=======================================================================
 2// GridEventInfo.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 GridForge.Configuration;
 10using GridForge.Spatial;
 11
 12namespace GridForge.Grids;
 13
 14/// <summary>
 15/// Immutable snapshot describing a grid at the time a world grid notification is raised.
 16/// </summary>
 17public readonly struct GridEventInfo
 18{
 19    /// <summary>
 20    /// The runtime token of the owning <see cref="GridWorld"/> instance.
 21    /// </summary>
 22    public readonly int WorldSpawnToken;
 23
 24    /// <summary>
 25    /// The stable slot index assigned to the grid within <see cref="GridWorld.ActiveGrids"/>.
 26    /// </summary>
 27    public readonly ushort GridIndex;
 28
 29    /// <summary>
 30    /// The unique spawn token for the specific grid instance occupying <see cref="GridIndex"/>.
 31    /// </summary>
 32    public readonly int GridSpawnToken;
 33
 34    /// <summary>
 35    /// The snapped configuration for the grid when the notification was raised.
 36    /// </summary>
 37    public readonly GridConfiguration Configuration;
 38
 39    /// <summary>
 40    /// The per-grid version recorded when the notification was raised.
 41    /// </summary>
 42    public readonly uint GridVersion;
 43
 44    /// <summary>
 45    /// The reason this grid event was raised.
 46    /// </summary>
 47    public readonly GridEventKind ChangeKind;
 48
 49    /// <summary>
 50    /// The changed voxel index for voxel-scoped grid events.
 51    /// </summary>
 52    public readonly VoxelIndex VoxelIndex;
 53
 54    /// <summary>
 55    /// The minimum world-space bounds affected by this event.
 56    /// </summary>
 57    public readonly Vector3d AffectedBoundsMin;
 58
 59    /// <summary>
 60    /// The maximum world-space bounds affected by this event.
 61    /// </summary>
 62    public readonly Vector3d AffectedBoundsMax;
 63
 64    /// <summary>
 65    /// The minimum snapped bounds of the grid.
 66    /// </summary>
 1367    public readonly Vector3d BoundsMin => Configuration.BoundsMin;
 68
 69    /// <summary>
 70    /// The maximum snapped bounds of the grid.
 71    /// </summary>
 1372    public readonly Vector3d BoundsMax => Configuration.BoundsMax;
 73
 74    /// <summary>
 75    /// Initializes a new immutable grid event snapshot.
 76    /// </summary>
 77    public GridEventInfo(
 78        int worldSpawnToken,
 79        ushort gridIndex,
 80        int gridSpawnToken,
 81        GridConfiguration configuration,
 82        uint gridVersion,
 83        GridEventKind changeKind = GridEventKind.Unspecified,
 84        VoxelIndex voxelIndex = default,
 85        Vector3d affectedBoundsMin = default,
 86        Vector3d affectedBoundsMax = default)
 87    {
 185188        WorldSpawnToken = worldSpawnToken;
 185189        GridIndex = gridIndex;
 185190        GridSpawnToken = gridSpawnToken;
 185191        Configuration = configuration;
 185192        GridVersion = gridVersion;
 185193        ChangeKind = changeKind;
 185194        VoxelIndex = voxelIndex;
 185195        AffectedBoundsMin = !voxelIndex.IsAllocated && affectedBoundsMin == default && affectedBoundsMax == default
 185196            ? configuration.BoundsMin
 185197            : affectedBoundsMin;
 185198        AffectedBoundsMax = !voxelIndex.IsAllocated && affectedBoundsMin == default && affectedBoundsMax == default
 185199            ? configuration.BoundsMax
 1851100            : affectedBoundsMax;
 1851101    }
 102
 103    /// <summary>
 104    /// Creates an exact bounds key from the stored grid configuration.
 105    /// </summary>
 1106    public readonly BoundsKey ToBoundsKey() => Configuration.ToBoundsKey();
 107}