| | | 1 | | //======================================================================= |
| | | 2 | | // GridNavigationBaseline.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 | | |
| | | 8 | | using System; |
| | | 9 | | using GridForge.Configuration; |
| | | 10 | | |
| | | 11 | | namespace GridForge.Grids; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Atomic requested-address snapshot for initializing an external navigation overlay. |
| | | 15 | | /// </summary> |
| | | 16 | | public sealed class GridNavigationBaseline |
| | | 17 | | { |
| | | 18 | | private readonly NavigationBaselineVoxelState[] _voxelStates; |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// The world-local committed change sequence captured with the state. |
| | | 22 | | /// </summary> |
| | | 23 | | public ulong CapturedChangeSequence { get; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// The exact process-unique identity of the source world. |
| | | 27 | | /// </summary> |
| | | 28 | | public long WorldSpawnToken { get; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// The exact world-local generation of the active grid. |
| | | 32 | | /// </summary> |
| | | 33 | | public long GridSpawnToken { get; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// The last world-local change sequence applied to this exact grid generation. |
| | | 37 | | /// Unrelated grids do not advance this value. |
| | | 38 | | /// </summary> |
| | | 39 | | public ulong GridLastChangeSequence { get; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// The active grid's recyclable world-local slot. |
| | | 43 | | /// </summary> |
| | | 44 | | public ushort GridIndex { get; } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// The requested normalized configuration identity. |
| | | 48 | | /// </summary> |
| | | 49 | | public GridConfigurationKey ConfigurationKey { get; } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Requested address states in the caller's validated ascending order. |
| | | 53 | | /// </summary> |
| | 4 | 54 | | public ReadOnlySpan<NavigationBaselineVoxelState> VoxelStates => _voxelStates; |
| | | 55 | | |
| | 6 | 56 | | internal GridNavigationBaseline( |
| | 6 | 57 | | ulong capturedChangeSequence, |
| | 6 | 58 | | long worldSpawnToken, |
| | 6 | 59 | | long gridSpawnToken, |
| | 6 | 60 | | ulong gridLastChangeSequence, |
| | 6 | 61 | | ushort gridIndex, |
| | 6 | 62 | | GridConfigurationKey configurationKey, |
| | 6 | 63 | | NavigationBaselineVoxelState[] voxelStates) |
| | | 64 | | { |
| | 6 | 65 | | CapturedChangeSequence = capturedChangeSequence; |
| | 6 | 66 | | WorldSpawnToken = worldSpawnToken; |
| | 6 | 67 | | GridSpawnToken = gridSpawnToken; |
| | 6 | 68 | | GridLastChangeSequence = gridLastChangeSequence; |
| | 6 | 69 | | GridIndex = gridIndex; |
| | 6 | 70 | | ConfigurationKey = configurationKey; |
| | 6 | 71 | | _voxelStates = voxelStates; |
| | 6 | 72 | | } |
| | | 73 | | } |