| | | 1 | | using FixedMathSharp; |
| | | 2 | | using GridForge.Spatial; |
| | | 3 | | using SwiftCollections; |
| | | 4 | | |
| | | 5 | | namespace Trailblazer.Pathing; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Stores conservative solid-partition connectivity snapshots for one pathing context. |
| | | 9 | | /// </summary> |
| | | 10 | | internal sealed class SolidPartitionReachabilityState |
| | | 11 | | { |
| | | 12 | | internal object Lock { get; } = new(); |
| | | 13 | | |
| | | 14 | | internal SwiftDictionary<WorldVoxelIndex, SolidChartPartition> PassablePartitions { get; } = new(); |
| | | 15 | | |
| | | 16 | | internal SwiftList<SolidChartPartition> ComponentRoots { get; } = new(); |
| | | 17 | | |
| | | 18 | | internal SwiftQueue<SolidChartPartition> ComponentQueue { get; } = new(); |
| | | 19 | | |
| | | 20 | | internal ReachabilitySnapshotKey ActiveSnapshotKey; |
| | | 21 | | |
| | | 22 | | internal bool HasActiveSnapshot; |
| | | 23 | | |
| | | 24 | | internal int ActiveSnapshotId; |
| | | 25 | | |
| | 961 | 26 | | internal int ActiveSnapshotVersion = -1; |
| | | 27 | | |
| | | 28 | | internal long SnapshotBuildCount; |
| | | 29 | | |
| | | 30 | | internal int Version; |
| | | 31 | | } |
| | | 32 | | |
| | | 33 | | internal readonly struct ReachabilitySnapshotKey : System.IEquatable<ReachabilitySnapshotKey> |
| | | 34 | | { |
| | | 35 | | internal ReachabilitySnapshotKey(Fixed64 unitSize, Fixed64 maxClimbHeight) |
| | | 36 | | { |
| | | 37 | | UnitSize = unitSize; |
| | | 38 | | MaxClimbHeight = maxClimbHeight; |
| | | 39 | | } |
| | | 40 | | |
| | | 41 | | internal Fixed64 UnitSize { get; } |
| | | 42 | | |
| | | 43 | | internal Fixed64 MaxClimbHeight { get; } |
| | | 44 | | |
| | | 45 | | public bool Equals(ReachabilitySnapshotKey other) |
| | | 46 | | { |
| | | 47 | | return UnitSize == other.UnitSize && MaxClimbHeight == other.MaxClimbHeight; |
| | | 48 | | } |
| | | 49 | | |
| | | 50 | | public override bool Equals(object? obj) |
| | | 51 | | { |
| | | 52 | | return obj is ReachabilitySnapshotKey other && Equals(other); |
| | | 53 | | } |
| | | 54 | | |
| | | 55 | | public override int GetHashCode() |
| | | 56 | | { |
| | | 57 | | unchecked |
| | | 58 | | { |
| | | 59 | | int hash = 17; |
| | | 60 | | hash = (hash * 31) + UnitSize.GetHashCode(); |
| | | 61 | | hash = (hash * 31) + MaxClimbHeight.GetHashCode(); |
| | | 62 | | return hash; |
| | | 63 | | } |
| | | 64 | | } |
| | | 65 | | } |