| | | 1 | | using Chronicler; |
| | | 2 | | using FixedMathSharp; |
| | | 3 | | using System; |
| | | 4 | | |
| | | 5 | | namespace Trailblazer.Navigation.Motor; |
| | | 6 | | |
| | | 7 | | /// <summary> |
| | | 8 | | /// Represents the state of the surface the scout is interacting with, including surface movement and normal data. |
| | | 9 | | /// </summary> |
| | | 10 | | [Serializable] |
| | | 11 | | public struct GroundCondition : IRecordable |
| | | 12 | | { |
| | | 13 | | /// <summary> |
| | | 14 | | /// The host-provided sampled platform state the scout is currently standing on. |
| | | 15 | | /// </summary> |
| | | 16 | | public PlatformSnapshot Platform; |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// The current surface friction applied to movement. |
| | | 20 | | /// </summary> |
| | | 21 | | public Fixed64 SurfaceFriction; |
| | | 22 | | |
| | | 23 | | /// <summary> |
| | | 24 | | /// Determines how the scout inherits movement from the ground surface when the sampled platform is not inert. |
| | | 25 | | /// </summary> |
| | | 26 | | public MotionTransfer MotionTransferState; |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Convenience normal derived from the sampled platform transform. |
| | | 30 | | /// </summary> |
| | 648 | 31 | | public readonly Vector3d GroundNormal => Platform.Active ? Platform.Transform.Up : Vector3d.Zero; |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Creates a new GroundCondition instance that is a copy of the current instance. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <remarks> |
| | | 37 | | /// The returned object is a shallow copy. Reference-type properties are not deeply cloned. |
| | | 38 | | /// </remarks> |
| | | 39 | | /// <returns> |
| | | 40 | | /// A new GroundCondition object with the same Platform, SurfaceFriction, and MotionTransferState values as the curr |
| | | 41 | | /// </returns> |
| | 127 | 42 | | public GroundCondition Clone() => new() |
| | 127 | 43 | | { |
| | 127 | 44 | | Platform = Platform, |
| | 127 | 45 | | SurfaceFriction = SurfaceFriction, |
| | 127 | 46 | | MotionTransferState = MotionTransferState |
| | 127 | 47 | | }; |
| | | 48 | | |
| | | 49 | | /// <inheritdoc/> |
| | | 50 | | public void RecordData(IChronicler chronicler) |
| | | 51 | | { |
| | 70 | 52 | | chronicler.LookDeepStruct(ref Platform, "Platform"); |
| | 70 | 53 | | chronicler.LookValue(ref SurfaceFriction, "SurfaceFriction", Fixed64.Zero); |
| | 70 | 54 | | chronicler.LookValue(ref MotionTransferState, "MotionTransferState", MotionTransfer.None); |
| | 70 | 55 | | } |
| | | 56 | | } |