< Summary

Information
Class: Trailblazer.Navigation.Motor.FallLocomotion
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Motor/Locomotion/FallLocomotion.cs
Line coverage
100%
Covered lines: 27
Uncovered lines: 0
Coverable lines: 27
Total lines: 112
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
.ctor()100%11100%
get_IsEnabled()100%11100%
set_IsEnabled(...)50%22100%
get_FallHeight()100%11100%
RecordData(...)100%44100%

File(s)

/home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Motor/Locomotion/FallLocomotion.cs

#LineLine coverage
 1using Chronicler;
 2using FixedMathSharp;
 3using Trailblazer.Support;
 4
 5namespace Trailblazer.Navigation.Motor;
 6
 7/// <summary>
 8/// Handles the scout’s behavior when falling, including tracking fall distance and applying movement constraints.
 9/// </summary>
 10public class FallLocomotion : ILocomotion
 11{
 12    #region Constants
 13
 14    /// <summary>
 15    /// The default maximum height a scout can fall before a fatal impact occurs.
 16    /// </summary>
 117    public static readonly Fixed64 DefaultMaxFallHeight = (Fixed64)30;
 18
 19    /// <summary>
 20    /// Default movement control multiplier when falling.
 21    /// Reduces movement responsiveness to simulate loss of control while airborne.
 22    /// </summary>
 123    public static readonly Fixed64 DefaultFallControlMultiplier = (Fixed64)0.1875f; // 50% control when falling
 24
 25    #endregion
 26
 27    #region Configuration State
 28
 29    /// <summary>
 30    /// Determines whether falling mechanics are enabled.
 31    /// If disabled, the scout will not experience fall behavior.
 32    /// </summary>
 82333    private bool _isEnabled = true;
 34
 35    /// <summary>
 36    /// The maximum allowable fall height before the scout reaches a critical threshold (e.g., death or heavy impact).
 37    /// </summary>
 82338    public Fixed64 MaxFallHeight = DefaultMaxFallHeight;
 39
 40    /// <summary>
 41    /// A multiplier controlling how much movement input affects the scout while falling.
 42    /// Lower values reduce movement responsiveness.
 43    /// </summary>
 82344    public Fixed64 FallControlMultiplier = DefaultFallControlMultiplier;
 45
 46    #endregion
 47
 48    #region Transient State
 49
 50    /// <inheritdoc cref="ILocomotion.IsEnabled"/>
 51    public bool IsEnabled
 52    {
 207153        get => _isEnabled;
 54        set
 55        {
 256            _isEnabled = value;
 257            if (!value)
 258                this.ClearTransientState();
 259        }
 60    }
 61
 62    /// <summary>
 63    /// Indicates whether the scout is currently falling.
 64    /// </summary>
 65    [Transient]
 66    public bool IsFalling { get; set; }
 67
 68    /// <summary>
 69    /// The vertical position where the scout started falling.
 70    /// </summary>
 71    [Transient]
 72    public Fixed64 FallStart { get; set; }
 73
 74    /// <summary>
 75    /// The vertical position where the scout landed.
 76    /// </summary>
 77    [Transient]
 78    public Fixed64 FallEnd { get; set; }
 79
 80    /// <summary>
 81    /// The total distance fallen, calculated as the difference between <see cref="FallStart"/> and <see cref="FallEnd"/
 82    /// </summary>
 1983    public Fixed64 FallHeight => FallStart - FallEnd;
 84
 85    #endregion
 86
 87    /// <inheritdoc />
 88    public void RecordData(IChronicler chronicler)
 89    {
 10690        RecordValues.Look(chronicler, ref _isEnabled, "IsEnabled", true);
 10691        RecordValues.Look(chronicler, ref MaxFallHeight, "MaxFallHeight", DefaultMaxFallHeight);
 10692        RecordValues.Look(chronicler, ref FallControlMultiplier, "FallControlMultiplier", DefaultFallControlMultiplier);
 93
 10694        bool isFalling = IsFalling;
 10695        Fixed64 fallStart = FallStart;
 10696        Fixed64 fallEnd = FallEnd;
 97
 10698        RecordValues.Look(chronicler, ref isFalling, "IsFalling", false);
 10699        RecordValues.Look(chronicler, ref fallStart, "FallStart", Fixed64.Zero);
 106100        RecordValues.Look(chronicler, ref fallEnd, "FallEnd", Fixed64.Zero);
 101
 106102        if (chronicler.Mode == SerializationMode.Loading)
 103        {
 53104            IsFalling = isFalling;
 53105            FallStart = fallStart;
 53106            FallEnd = fallEnd;
 107
 53108            if (!_isEnabled)
 2109                this.ClearTransientState();
 110        }
 106111    }
 112}