< 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: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 145
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_ChangeSequence()100%11100%
get_CauseId()100%11100%
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 world-owned ordering and cause identity for this committed mutation.
 21    /// </summary>
 22    public readonly GridChangeStamp ChangeStamp;
 23
 24    /// <summary>
 25    /// The process-unique 64-bit runtime allocation token of the owning <see cref="GridWorld"/> instance.
 26    /// </summary>
 27    public readonly long WorldSpawnToken;
 28
 29    /// <summary>
 30    /// The stable slot index assigned to the grid within <see cref="GridWorld.ActiveGrids"/>.
 31    /// </summary>
 32    public readonly ushort GridIndex;
 33
 34    /// <summary>
 35    /// The 64-bit world-local allocation generation for the grid occupying <see cref="GridIndex"/>.
 36    /// </summary>
 37    public readonly long GridSpawnToken;
 38
 39    /// <summary>
 40    /// The snapped configuration for the grid when the notification was raised.
 41    /// </summary>
 42    public readonly GridConfiguration Configuration;
 43
 44    /// <summary>
 45    /// The per-grid version recorded when the notification was raised.
 46    /// </summary>
 47    public readonly uint GridVersion;
 48
 49    /// <summary>
 50    /// The reason this grid event was raised.
 51    /// </summary>
 52    public readonly GridEventKind ChangeKind;
 53
 54    /// <summary>
 55    /// The changed voxel index for voxel-scoped grid events.
 56    /// </summary>
 57    public readonly VoxelIndex VoxelIndex;
 58
 59    /// <summary>
 60    /// The minimum world-space bounds affected by this event.
 61    /// </summary>
 62    public readonly Vector3d AffectedBoundsMin;
 63
 64    /// <summary>
 65    /// The maximum world-space bounds affected by this event.
 66    /// </summary>
 67    public readonly Vector3d AffectedBoundsMax;
 68
 69    /// <summary>
 70    /// Whether this event contains an exact post-mutation voxel state.
 71    /// </summary>
 72    public readonly bool HasVoxelState;
 73
 74    /// <summary>
 75    /// Whether the addressed physical voxel exists after the mutation.
 76    /// </summary>
 77    public readonly bool IsVoxelPresent;
 78
 79    /// <summary>
 80    /// The addressed voxel's obstacle count after the mutation.
 81    /// </summary>
 82    public readonly byte ObstacleCount;
 83
 84    /// <summary>
 85    /// The world-local commit order of this event.
 86    /// </summary>
 350787    public ulong ChangeSequence => ChangeStamp.Sequence;
 88
 89    /// <summary>
 90    /// The logical cause shared with exact notifications for the same mutation.
 91    /// </summary>
 292    public ulong CauseId => ChangeStamp.CauseId;
 93
 94    /// <summary>
 95    /// The minimum snapped bounds of the grid.
 96    /// </summary>
 1797    public readonly Vector3d BoundsMin => Configuration.BoundsMin;
 98
 99    /// <summary>
 100    /// The maximum snapped bounds of the grid.
 101    /// </summary>
 17102    public readonly Vector3d BoundsMax => Configuration.BoundsMax;
 103
 104    /// <summary>
 105    /// Initializes a new immutable grid event snapshot.
 106    /// </summary>
 107    public GridEventInfo(
 108        long worldSpawnToken,
 109        ushort gridIndex,
 110        long gridSpawnToken,
 111        GridConfiguration configuration,
 112        uint gridVersion,
 113        GridEventKind changeKind = GridEventKind.Unspecified,
 114        VoxelIndex voxelIndex = default,
 115        Vector3d affectedBoundsMin = default,
 116        Vector3d affectedBoundsMax = default,
 117        GridChangeStamp changeStamp = default,
 118        bool hasVoxelState = false,
 119        bool isVoxelPresent = false,
 120        byte obstacleCount = 0)
 121    {
 3495122        ChangeStamp = changeStamp;
 3495123        WorldSpawnToken = worldSpawnToken;
 3495124        GridIndex = gridIndex;
 3495125        GridSpawnToken = gridSpawnToken;
 3495126        Configuration = configuration;
 3495127        GridVersion = gridVersion;
 3495128        ChangeKind = changeKind;
 3495129        VoxelIndex = voxelIndex;
 3495130        AffectedBoundsMin = !voxelIndex.IsAllocated && affectedBoundsMin == default && affectedBoundsMax == default
 3495131            ? configuration.BoundsMin
 3495132            : affectedBoundsMin;
 3495133        AffectedBoundsMax = !voxelIndex.IsAllocated && affectedBoundsMin == default && affectedBoundsMax == default
 3495134            ? configuration.BoundsMax
 3495135            : affectedBoundsMax;
 3495136        HasVoxelState = hasVoxelState;
 3495137        IsVoxelPresent = isVoxelPresent;
 3495138        ObstacleCount = obstacleCount;
 3495139    }
 140
 141    /// <summary>
 142    /// Creates an exact bounds key from the stored grid configuration.
 143    /// </summary>
 1144    public readonly BoundsKey ToBoundsKey() => Configuration.ToBoundsKey();
 145}