< Summary

Information
Class: Trailblazer.Navigation.Motor.SlideLocomotion
Assembly: Trailblazer
File(s): /home/runner/work/Trailblazer/Trailblazer/src/Trailblazer/Navigation/Motor/Locomotion/SlideLocomotion.cs
Line coverage
100%
Covered lines: 23
Uncovered lines: 0
Coverable lines: 23
Total lines: 109
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%
RecordData(...)100%44100%

File(s)

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

#LineLine coverage
 1using Chronicler;
 2using FixedMathSharp;
 3using Trailblazer.Support;
 4
 5namespace Trailblazer.Navigation.Motor;
 6
 7/// <summary>
 8/// Handles the scout's sliding behavior when traversing steep surfaces.
 9/// </summary>
 10/// <remarks>
 11/// This locomotion module determines when the scout should slide based on terrain steepness
 12/// and controls how much influence the scout has over the slide direction and speed.
 13/// </remarks>
 14public class SlideLocomotion : ILocomotion
 15{
 16    #region Constants
 17
 18    /// <summary>
 19    /// The default speed at which the scout slides down steep surfaces.
 20    /// </summary>
 121    public static readonly Fixed64 DefaultSlidingSpeed = (Fixed64)30;
 22
 23    /// <summary>
 24    /// The default amount of control the scout has while sliding sideways.
 25    /// </summary>
 26    /// <remarks>
 27    /// A value of 0.5 allows the scout to slide sideways at half the speed of downward sliding.
 28    /// </remarks>
 129    public static readonly Fixed64 DefaultSidewaysControl = (Fixed64)1;
 30
 31    /// <summary>
 32    /// The default amount the scout can influence sliding speed.
 33    /// </summary>
 34    /// <remarks>
 35    /// A value of 0.5 allows the scout to increase sliding speed up to 150% or reduce it to 50%.
 36    /// </remarks>
 137    public static readonly Fixed64 DefaultSpeedControl = (Fixed64)0.5d;
 38
 39    #endregion
 40
 41    #region Configuration State
 42
 43    /// <summary>
 44    /// Determines whether sliding mechanics are enabled.
 45    /// </summary>
 78346    private bool _isEnabled = true;
 47
 48    /// <summary>
 49    /// The speed at which the scout slides when on a steep surface.
 50    /// </summary>
 78351    public Fixed64 SlidingSpeed = DefaultSlidingSpeed;
 52
 53    /// <summary>
 54    /// Determines how much control the scout has while sliding sideways.
 55    /// </summary>
 56    /// <remarks>
 57    /// A higher value increases lateral movement freedom during a slide.
 58    /// </remarks>
 78359    public Fixed64 SidewaysControl = DefaultSidewaysControl;
 60
 61    /// <summary>
 62    /// Determines how much the scout can influence sliding speed.
 63    /// </summary>
 78364    public Fixed64 SpeedControl = DefaultSpeedControl;
 65
 66    #endregion
 67
 68    #region Transient State
 69
 70    /// <inheritdoc cref="ILocomotion.IsEnabled"/>
 71    public bool IsEnabled
 72    {
 22273        get => _isEnabled;
 74        set
 75        {
 176            _isEnabled = value;
 177            if (!_isEnabled)
 178                this.ClearTransientState();
 179        }
 80    }
 81
 82    /// <summary>
 83    /// Indicates whether the scout is currently sliding.
 84    /// </summary>
 85    [Transient]
 86    public bool IsSliding { get; set; }
 87
 88    #endregion
 89
 90    /// <inheritdoc />
 91    public void RecordData(IChronicler chronicler)
 92    {
 10093        RecordValues.Look(chronicler, ref _isEnabled, "IsEnabled", true);
 10094        RecordValues.Look(chronicler, ref SlidingSpeed, "SlidingSpeed", DefaultSlidingSpeed);
 10095        RecordValues.Look(chronicler, ref SidewaysControl, "SidewaysControl", DefaultSidewaysControl);
 10096        RecordValues.Look(chronicler, ref SpeedControl, "SpeedControl", DefaultSpeedControl);
 97
 10098        bool isSliding = IsSliding;
 10099        RecordValues.Look(chronicler, ref isSliding, "IsSliding", false);
 100
 100101        if (chronicler.Mode == SerializationMode.Loading)
 102        {
 50103            IsSliding = isSliding;
 104
 50105            if (!_isEnabled)
 2106                this.ClearTransientState();
 107        }
 100108    }
 109}