< 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: 116
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
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(...)100%22100%
RecordData(...)100%44100%

File(s)

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

#LineLine coverage
 1//=======================================================================
 2// SlideLocomotion.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
 8using Chronicler;
 9using FixedMathSharp;
 10using Trailblazer.Support;
 11
 12namespace Trailblazer.Navigation.Motor;
 13
 14/// <summary>
 15/// Handles the scout's sliding behavior when traversing steep surfaces.
 16/// </summary>
 17/// <remarks>
 18/// This locomotion module determines when the scout should slide based on terrain steepness
 19/// and controls how much influence the scout has over the slide direction and speed.
 20/// </remarks>
 21public class SlideLocomotion : ILocomotion
 22{
 23    #region Constants
 24
 25    /// <summary>
 26    /// The default speed at which the scout slides down steep surfaces.
 27    /// </summary>
 128    public static readonly Fixed64 DefaultSlidingSpeed = (Fixed64)30;
 29
 30    /// <summary>
 31    /// The default amount of control the scout has while sliding sideways.
 32    /// </summary>
 33    /// <remarks>
 34    /// A value of 0.5 allows the scout to slide sideways at half the speed of downward sliding.
 35    /// </remarks>
 136    public static readonly Fixed64 DefaultSidewaysControl = (Fixed64)1;
 37
 38    /// <summary>
 39    /// The default amount the scout can influence sliding speed.
 40    /// </summary>
 41    /// <remarks>
 42    /// A value of 0.5 allows the scout to increase sliding speed up to 150% or reduce it to 50%.
 43    /// </remarks>
 144    public static readonly Fixed64 DefaultSpeedControl = Fixed64.Half;
 45
 46    #endregion
 47
 48    #region Configuration State
 49
 50    /// <summary>
 51    /// Determines whether sliding mechanics are enabled.
 52    /// </summary>
 114953    private bool _isEnabled = true;
 54
 55    /// <summary>
 56    /// The speed at which the scout slides when on a steep surface.
 57    /// </summary>
 114958    public Fixed64 SlidingSpeed = DefaultSlidingSpeed;
 59
 60    /// <summary>
 61    /// Determines how much control the scout has while sliding sideways.
 62    /// </summary>
 63    /// <remarks>
 64    /// A higher value increases lateral movement freedom during a slide.
 65    /// </remarks>
 114966    public Fixed64 SidewaysControl = DefaultSidewaysControl;
 67
 68    /// <summary>
 69    /// Determines how much the scout can influence sliding speed.
 70    /// </summary>
 114971    public Fixed64 SpeedControl = DefaultSpeedControl;
 72
 73    #endregion
 74
 75    #region Transient State
 76
 77    /// <inheritdoc cref="ILocomotion.IsEnabled"/>
 78    public bool IsEnabled
 79    {
 27480        get => _isEnabled;
 81        set
 82        {
 283            _isEnabled = value;
 284            if (!_isEnabled)
 185                this.ClearTransientState();
 286        }
 87    }
 88
 89    /// <summary>
 90    /// Indicates whether the scout is currently sliding.
 91    /// </summary>
 92    [Transient]
 93    public bool IsSliding { get; set; }
 94
 95    #endregion
 96
 97    /// <inheritdoc />
 98    public void RecordData(IChronicler chronicler)
 99    {
 158100        RecordValues.Look(chronicler, ref _isEnabled, "IsEnabled", true);
 158101        RecordValues.Look(chronicler, ref SlidingSpeed, "SlidingSpeed", DefaultSlidingSpeed);
 158102        RecordValues.Look(chronicler, ref SidewaysControl, "SidewaysControl", DefaultSidewaysControl);
 158103        RecordValues.Look(chronicler, ref SpeedControl, "SpeedControl", DefaultSpeedControl);
 104
 158105        bool isSliding = IsSliding;
 158106        RecordValues.Look(chronicler, ref isSliding, "IsSliding", false);
 107
 158108        if (chronicler.Mode == SerializationMode.Loading)
 109        {
 74110            IsSliding = isSliding;
 111
 74112            if (!_isEnabled)
 2113                this.ClearTransientState();
 114        }
 158115    }
 116}