| | | 1 | | using FixedMathSharp; |
| | | 2 | | using GridForge.Configuration; |
| | | 3 | | |
| | | 4 | | namespace GridForge.Grids; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Immutable snapshot describing a grid at the time a world grid notification is raised. |
| | | 8 | | /// </summary> |
| | | 9 | | public readonly struct GridEventInfo |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// The runtime token of the owning <see cref="GridWorld"/> instance. |
| | | 13 | | /// </summary> |
| | | 14 | | public readonly int WorldSpawnToken; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// The stable slot index assigned to the grid within <see cref="GridWorld.ActiveGrids"/>. |
| | | 18 | | /// </summary> |
| | | 19 | | public readonly ushort GridIndex; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// The unique spawn token for the specific grid instance occupying <see cref="GridIndex"/>. |
| | | 23 | | /// </summary> |
| | | 24 | | public readonly int GridSpawnToken; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// The snapped configuration for the grid when the notification was raised. |
| | | 28 | | /// </summary> |
| | | 29 | | public readonly GridConfiguration Configuration; |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// The per-grid version recorded when the notification was raised. |
| | | 33 | | /// </summary> |
| | | 34 | | public readonly uint GridVersion; |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// The minimum snapped bounds of the grid. |
| | | 38 | | /// </summary> |
| | 11 | 39 | | public readonly Vector3d BoundsMin => Configuration.BoundsMin; |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// The maximum snapped bounds of the grid. |
| | | 43 | | /// </summary> |
| | 10 | 44 | | public readonly Vector3d BoundsMax => Configuration.BoundsMax; |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Initializes a new immutable grid event snapshot. |
| | | 48 | | /// </summary> |
| | | 49 | | public GridEventInfo( |
| | | 50 | | int worldSpawnToken, |
| | | 51 | | ushort gridIndex, |
| | | 52 | | int gridSpawnToken, |
| | | 53 | | GridConfiguration configuration, |
| | | 54 | | uint gridVersion) |
| | | 55 | | { |
| | 1433 | 56 | | WorldSpawnToken = worldSpawnToken; |
| | 1433 | 57 | | GridIndex = gridIndex; |
| | 1433 | 58 | | GridSpawnToken = gridSpawnToken; |
| | 1433 | 59 | | Configuration = configuration; |
| | 1433 | 60 | | GridVersion = gridVersion; |
| | 1433 | 61 | | } |
| | | 62 | | |
| | | 63 | | /// <summary> |
| | | 64 | | /// Creates an exact bounds key from the stored grid configuration. |
| | | 65 | | /// </summary> |
| | 1 | 66 | | public readonly BoundsKey ToBoundsKey() => Configuration.ToBoundsKey(); |
| | | 67 | | } |