| | | 1 | | //======================================================================= |
| | | 2 | | // TrekCondition.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 System.Runtime.CompilerServices; |
| | | 10 | | using Chronicler; |
| | | 11 | | using FixedMathSharp; |
| | | 12 | | |
| | | 13 | | namespace Trailblazer.Navigation.Motor; |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// Represents the traversal state of a scout, including its movement medium and surface interactions. |
| | | 17 | | /// </summary> |
| | | 18 | | [Serializable] |
| | | 19 | | public struct TrekCondition : IRecordable |
| | | 20 | | { |
| | | 21 | | /// <summary> |
| | | 22 | | /// Defines the medium in which the scout is currently moving. |
| | | 23 | | /// </summary> |
| | | 24 | | public TraversalMedium Medium; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// Stores the height of the current surface, typically used for ground and water interactions. |
| | | 28 | | /// </summary> |
| | | 29 | | public Fixed64 SurfaceLevel; |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Stores the height of the ceiling above the scout, if applicable. |
| | | 33 | | /// Defaults to Fixed64.MaxValue, meaning no ceiling. |
| | | 34 | | /// </summary> |
| | 3719 | 35 | | public Fixed64 CeilingLevel = Fixed64.MaxValue; |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Contains data about the ground state, if applicable. |
| | | 39 | | /// </summary> |
| | | 40 | | public GroundCondition? GroundState; |
| | | 41 | | |
| | | 42 | | /// <summary> |
| | | 43 | | /// Initializes a new instance of the TrekCondition class. |
| | | 44 | | /// </summary> |
| | 3719 | 45 | | public TrekCondition() { } |
| | | 46 | | |
| | | 47 | | /// <summary> |
| | | 48 | | /// Creates a deep copy of the current <see cref="TrekCondition"/> instance. |
| | | 49 | | /// </summary> |
| | | 50 | | [MethodImpl(MethodImplOptions.AggressiveInlining)] |
| | 331 | 51 | | public TrekCondition Clone() => new() |
| | 331 | 52 | | { |
| | 331 | 53 | | Medium = Medium, |
| | 331 | 54 | | SurfaceLevel = SurfaceLevel, |
| | 331 | 55 | | GroundState = GroundState?.Clone(), |
| | 331 | 56 | | CeilingLevel = CeilingLevel |
| | 331 | 57 | | }; |
| | | 58 | | |
| | | 59 | | /// <summary> |
| | | 60 | | /// Resets the traversal condition to default values, indicating an unknown state. |
| | | 61 | | /// </summary> |
| | | 62 | | public void Reset() |
| | | 63 | | { |
| | 29 | 64 | | Medium = TraversalMedium.Unknown; |
| | 29 | 65 | | SurfaceLevel = Fixed64.Zero; |
| | 29 | 66 | | GroundState = null; |
| | 29 | 67 | | CeilingLevel = Fixed64.MaxValue; |
| | 29 | 68 | | } |
| | | 69 | | |
| | | 70 | | /// <inheritdoc/> |
| | | 71 | | public void RecordData(IChronicler chronicler) |
| | | 72 | | { |
| | 229 | 73 | | RecordValues.Look(chronicler, ref Medium, "Medium", TraversalMedium.Unknown); |
| | 229 | 74 | | RecordValues.Look(chronicler, ref SurfaceLevel, "SurfaceLevel", Fixed64.Zero); |
| | 229 | 75 | | RecordValues.Look(chronicler, ref CeilingLevel, "CeilingLevel", Fixed64.MaxValue); |
| | 229 | 76 | | RecordNullableDeep.Look(chronicler, ref GroundState, "GroundState"); |
| | 229 | 77 | | } |
| | | 78 | | } |