// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using System.Collections.Generic; using System.Linq; using osu.Game.Rulesets.Difficulty.Preprocessing; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Difficulty.Skills { /// /// Used to processes strain values of s, keep track of strain levels caused by the processed objects /// and to calculate a final difficulty value representing the difficulty of hitting all the processed objects. /// public abstract class StrainDecaySkill : StrainSkill { /// /// Strain values are multiplied by this number for the given skill. Used to balance the value of different skills between each other. /// protected abstract double SkillMultiplier { get; } /// /// Determines how quickly strain decays for the given skill. /// For example a value of 0.15 indicates that strain decays to 15% of its original value in one second. /// protected abstract double StrainDecayBase { get; } /// /// The current strain level. /// protected double CurrentStrain { get; private set; } = 1; protected StrainDecaySkill(Mod[] mods) : base(mods) { } /// /// Retrieves the peak strain at a point in time. /// /// The time to retrieve the peak strain at. /// The peak strain. protected override double CalculateInitialStrain(double time) => CurrentStrain * strainDecay(time - Previous[0].StartTime); /// /// Returns the strain value of . This value is calculated with or without respect to previous objects. /// protected override double StrainValueAt(DifficultyHitObject current) { CurrentStrain *= strainDecay(current.DeltaTime); CurrentStrain += StrainValueOf(current) * SkillMultiplier; return CurrentStrain; } /// /// Calculates the strain value of a . This value is affected by previously processed objects. /// protected abstract double StrainValueOf(DifficultyHitObject current); private double strainDecay(double ms) => Math.Pow(StrainDecayBase, ms / 1000); } }