| | | 1 | | //======================================================================= |
| | | 2 | | // GridBoundaryContactRunStamp.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 SwiftCollections.Utility; |
| | | 10 | | |
| | | 11 | | namespace GridForge.Grids.Topology; |
| | | 12 | | |
| | | 13 | | /// <summary> |
| | | 14 | | /// Identifies the exact committed world revision bound by a boundary-contact cursor. |
| | | 15 | | /// </summary> |
| | | 16 | | public readonly struct GridBoundaryContactRunStamp : IEquatable<GridBoundaryContactRunStamp> |
| | | 17 | | { |
| | | 18 | | /// <summary>The process-unique world allocation identity.</summary> |
| | | 19 | | public long WorldSpawnToken { get; } |
| | | 20 | | |
| | | 21 | | /// <summary>The world-local structural generation.</summary> |
| | | 22 | | public uint WorldVersion { get; } |
| | | 23 | | |
| | | 24 | | /// <summary>The committed world-local change sequence.</summary> |
| | | 25 | | public ulong ChangeSequence { get; } |
| | | 26 | | |
| | | 27 | | internal GridBoundaryContactRunStamp( |
| | | 28 | | long worldSpawnToken, |
| | | 29 | | uint worldVersion, |
| | | 30 | | ulong changeSequence) |
| | | 31 | | { |
| | 17 | 32 | | WorldSpawnToken = worldSpawnToken; |
| | 17 | 33 | | WorldVersion = worldVersion; |
| | 17 | 34 | | ChangeSequence = changeSequence; |
| | 17 | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | | 38 | | public bool Equals(GridBoundaryContactRunStamp other) => |
| | 15 | 39 | | WorldSpawnToken == other.WorldSpawnToken |
| | 15 | 40 | | && WorldVersion == other.WorldVersion |
| | 15 | 41 | | && ChangeSequence == other.ChangeSequence; |
| | | 42 | | |
| | | 43 | | /// <inheritdoc /> |
| | | 44 | | public override bool Equals(object? obj) => |
| | 3 | 45 | | obj is GridBoundaryContactRunStamp other && Equals(other); |
| | | 46 | | |
| | | 47 | | /// <inheritdoc /> |
| | | 48 | | public override int GetHashCode() |
| | | 49 | | { |
| | 2 | 50 | | int hash = SwiftHashTools.CombineHashCodes( |
| | 2 | 51 | | WorldSpawnToken.GetHashCode(), |
| | 2 | 52 | | WorldVersion.GetHashCode()); |
| | 2 | 53 | | return SwiftHashTools.CombineHashCodes(hash, ChangeSequence.GetHashCode()); |
| | | 54 | | } |
| | | 55 | | |
| | | 56 | | /// <inheritdoc /> |
| | | 57 | | public static bool operator ==( |
| | | 58 | | GridBoundaryContactRunStamp left, |
| | 2 | 59 | | GridBoundaryContactRunStamp right) => left.Equals(right); |
| | | 60 | | |
| | | 61 | | /// <inheritdoc /> |
| | | 62 | | public static bool operator !=( |
| | | 63 | | GridBoundaryContactRunStamp left, |
| | 1 | 64 | | GridBoundaryContactRunStamp right) => !left.Equals(right); |
| | | 65 | | } |