| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationGridChangeScope.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 | | using GridForge.Grids; |
| | | 11 | | |
| | | 12 | | namespace Trailblazer.Pathing; |
| | | 13 | | |
| | | 14 | | /// <summary>Identifies one configuration-local GridForge change scope and its observed generation.</summary> |
| | | 15 | | internal readonly struct NavigationGridChangeScope : IEquatable<NavigationGridChangeScope> |
| | | 16 | | { |
| | | 17 | | internal NavigationGridChangeScope(in GridEventInfo eventInfo) |
| | | 18 | | { |
| | 2462 | 19 | | ConfigurationKey = eventInfo.Configuration.ToGridKey(); |
| | 2462 | 20 | | WorldSpawnToken = eventInfo.WorldSpawnToken; |
| | 2462 | 21 | | GridIndex = eventInfo.GridIndex; |
| | 2462 | 22 | | GridSpawnToken = eventInfo.GridSpawnToken; |
| | 2462 | 23 | | } |
| | | 24 | | |
| | | 25 | | internal NavigationGridChangeScope( |
| | | 26 | | GridConfigurationKey configurationKey, |
| | | 27 | | long worldSpawnToken, |
| | | 28 | | ushort gridIndex, |
| | | 29 | | long gridSpawnToken) |
| | | 30 | | { |
| | 118 | 31 | | ConfigurationKey = configurationKey; |
| | 118 | 32 | | WorldSpawnToken = worldSpawnToken; |
| | 118 | 33 | | GridIndex = gridIndex; |
| | 118 | 34 | | GridSpawnToken = gridSpawnToken; |
| | 118 | 35 | | } |
| | | 36 | | |
| | | 37 | | internal GridConfigurationKey ConfigurationKey { get; } |
| | | 38 | | |
| | | 39 | | internal long WorldSpawnToken { get; } |
| | | 40 | | |
| | | 41 | | internal ushort GridIndex { get; } |
| | | 42 | | |
| | | 43 | | internal long GridSpawnToken { get; } |
| | | 44 | | |
| | | 45 | | public bool Equals(NavigationGridChangeScope other) => |
| | 1729 | 46 | | ConfigurationKey.Equals(other.ConfigurationKey); |
| | | 47 | | |
| | 5 | 48 | | public override int GetHashCode() => ConfigurationKey.GetHashCode(); |
| | | 49 | | } |