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