| | | 1 | | //======================================================================= |
| | | 2 | | // NavigationCellEntry.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.Spatial; |
| | | 10 | | using SwiftCollections.Utility; |
| | | 11 | | |
| | | 12 | | namespace Trailblazer.Pathing; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Associates one topology-local address with its immutable authored cell payload. |
| | | 16 | | /// </summary> |
| | | 17 | | public readonly struct NavigationCellEntry : IEquatable<NavigationCellEntry> |
| | | 18 | | { |
| | | 19 | | /// <summary> |
| | | 20 | | /// The topology-local cell index. |
| | | 21 | | /// </summary> |
| | | 22 | | public VoxelIndex Index { get; } |
| | | 23 | | |
| | | 24 | | /// <summary> |
| | | 25 | | /// The complete authored cell payload. |
| | | 26 | | /// </summary> |
| | | 27 | | public NavigationCell Cell { get; } |
| | | 28 | | |
| | | 29 | | /// <summary> |
| | | 30 | | /// Creates an authored cell entry. |
| | | 31 | | /// </summary> |
| | | 32 | | public NavigationCellEntry(VoxelIndex index, NavigationCell cell) |
| | | 33 | | { |
| | 23146 | 34 | | Index = index; |
| | 23146 | 35 | | Cell = cell; |
| | 23146 | 36 | | } |
| | | 37 | | |
| | | 38 | | /// <inheritdoc/> |
| | | 39 | | public bool Equals(NavigationCellEntry other) => |
| | 19 | 40 | | Index.Equals(other.Index) && Cell.Equals(other.Cell); |
| | | 41 | | |
| | | 42 | | /// <inheritdoc/> |
| | 2 | 43 | | public override bool Equals(object? obj) => obj is NavigationCellEntry other && Equals(other); |
| | | 44 | | |
| | | 45 | | /// <inheritdoc/> |
| | | 46 | | public override int GetHashCode() => |
| | 14 | 47 | | SwiftHashTools.CombineHashCodes(Index.GetHashCode(), Cell.GetHashCode()); |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Tests two entries for value equality. |
| | | 51 | | /// </summary> |
| | 1 | 52 | | public static bool operator ==(NavigationCellEntry left, NavigationCellEntry right) => left.Equals(right); |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Tests two entries for value inequality. |
| | | 56 | | /// </summary> |
| | 1 | 57 | | public static bool operator !=(NavigationCellEntry left, NavigationCellEntry right) => !left.Equals(right); |
| | | 58 | | } |