< Summary

Information
Class: GridForge.Spatial.WorldVoxelIndex
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Spatial/WorldVoxelIndex.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 106
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
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%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%
ToString()100%11100%
GetHashCode()100%11100%
Equals(...)100%66100%
Equals(...)100%22100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Spatial/WorldVoxelIndex.cs

#LineLine coverage
 1using GridForge.Grids;
 2using SwiftCollections;
 3using System;
 4using System.Runtime.CompilerServices;
 5
 6namespace GridForge.Spatial;
 7
 8/// <summary>
 9/// Represents the world-scoped runtime identity of a voxel.
 10/// Used for uniquely identifying voxels across multiple grids and world instances.
 11/// </summary>
 12public struct WorldVoxelIndex : IEquatable<WorldVoxelIndex>
 13{
 14    #region Properties
 15
 16    /// <summary>
 17    /// The runtime token of the owning <see cref="GridWorld"/> instance.
 18    /// Used to reject stale or cross-world identities safely.
 19    /// </summary>
 20    public int WorldSpawnToken;
 21
 22    /// <summary>
 23    /// The world-local slot index of the grid in <see cref="GridWorld.ActiveGrids"/>.
 24    /// </summary>
 25    public ushort GridIndex;
 26
 27    /// <summary>
 28    /// The unique identifier generated by the grid during initialization.
 29    /// Used to ensure the correct instance is at the assigned <see cref="GridIndex"/>.
 30    /// </summary>
 31    public int GridSpawnToken;
 32
 33    /// <summary>
 34    /// The local coordinate of a voxel within the grid at <see cref="GridIndex"/>.
 35    /// </summary>
 36    public VoxelIndex VoxelIndex;
 37
 38    #endregion
 39
 40    #region Constructors
 41
 42    /// <summary>
 43    /// Initializes a new instance of <see cref="WorldVoxelIndex"/>, linking a voxel to a specific world and grid instan
 44    /// </summary>
 45    public WorldVoxelIndex(
 46        int worldSpawnToken,
 47        ushort gridIndex,
 48        int gridSpawnToken,
 49        VoxelIndex coord)
 50    {
 7816351        WorldSpawnToken = worldSpawnToken;
 7816352        GridIndex = gridIndex;
 7816353        GridSpawnToken = gridSpawnToken;
 7816354        VoxelIndex = coord;
 7816355    }
 56
 57    #endregion
 58
 59    #region operators
 60
 61    /// <inheritdoc/>
 62    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 63    public static bool operator ==(WorldVoxelIndex left, WorldVoxelIndex right)
 64    {
 265        return left.Equals(right);
 66    }
 67
 68    /// <inheritdoc/>
 69    [MethodImpl(MethodImplOptions.AggressiveInlining)]
 70    public static bool operator !=(WorldVoxelIndex left, WorldVoxelIndex right)
 71    {
 172        return !(left == right);
 73    }
 74
 75    #endregion
 76
 77    #region Overrides
 78
 79    /// <summary>
 80    /// Returns a string representation of the world-scoped voxel identity.
 81    /// </summary>
 82    public override readonly string ToString()
 83    {
 1684        return $"World: {WorldSpawnToken}; Grid: {GridIndex}; Coordinate: {VoxelIndex}";
 85    }
 86
 87    /// <summary>
 88    /// Computes a hash code for uniquely identifying this world-scoped voxel identity.
 89    /// </summary>
 90    public override readonly int GetHashCode() =>
 263591        SwiftHashTools.CombineHashCodes(WorldSpawnToken, GridSpawnToken, GridIndex, VoxelIndex);
 92
 93    /// <inheritdoc/>
 94    public readonly bool Equals(WorldVoxelIndex other)
 95    {
 133996        return WorldSpawnToken == other.WorldSpawnToken
 133997            && GridIndex == other.GridIndex
 133998            && GridSpawnToken == other.GridSpawnToken
 133999            && VoxelIndex.Equals(other.VoxelIndex);
 100    }
 101
 102    /// <inheritdoc/>
 2103    public override readonly bool Equals(object? obj) => obj is WorldVoxelIndex other && Equals(other);
 104
 105    #endregion
 106}