mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 22:35:23 +08:00
Expose current strain and retrieval of peak strain
This commit is contained in:
parent
da03084251
commit
485a951281
@ -41,7 +41,11 @@ namespace osu.Game.Rulesets.Difficulty.Skills
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly LimitedCapacityStack<DifficultyHitObject> Previous = new LimitedCapacityStack<DifficultyHitObject>(2); // Contained objects not used yet
|
protected readonly LimitedCapacityStack<DifficultyHitObject> Previous = new LimitedCapacityStack<DifficultyHitObject>(2); // Contained objects not used yet
|
||||||
|
|
||||||
private double currentStrain = 1; // We keep track of the strain level at all times throughout the beatmap.
|
/// <summary>
|
||||||
|
/// The current strain level.
|
||||||
|
/// </summary>
|
||||||
|
protected double CurrentStrain { get; private set; } = 1;
|
||||||
|
|
||||||
private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section.
|
private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section.
|
||||||
|
|
||||||
private readonly List<double> strainPeaks = new List<double>();
|
private readonly List<double> strainPeaks = new List<double>();
|
||||||
@ -51,10 +55,10 @@ namespace osu.Game.Rulesets.Difficulty.Skills
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Process(DifficultyHitObject current)
|
public void Process(DifficultyHitObject current)
|
||||||
{
|
{
|
||||||
currentStrain *= strainDecay(current.DeltaTime);
|
CurrentStrain *= strainDecay(current.DeltaTime);
|
||||||
currentStrain += StrainValueOf(current) * SkillMultiplier;
|
CurrentStrain += StrainValueOf(current) * SkillMultiplier;
|
||||||
|
|
||||||
currentSectionPeak = Math.Max(currentStrain, currentSectionPeak);
|
currentSectionPeak = Math.Max(CurrentStrain, currentSectionPeak);
|
||||||
|
|
||||||
Previous.Push(current);
|
Previous.Push(current);
|
||||||
}
|
}
|
||||||
@ -71,15 +75,22 @@ namespace osu.Game.Rulesets.Difficulty.Skills
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the initial strain level for a new section.
|
/// Sets the initial strain level for a new section.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="offset">The beginning of the new section in milliseconds.</param>
|
/// <param name="time">The beginning of the new section in milliseconds.</param>
|
||||||
public void StartNewSectionFrom(double offset)
|
public void StartNewSectionFrom(double time)
|
||||||
{
|
{
|
||||||
// The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
|
// The maximum strain of the new section is not zero by default, strain decays as usual regardless of section boundaries.
|
||||||
// This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
|
// This means we need to capture the strain level at the beginning of the new section, and use that as the initial peak level.
|
||||||
if (Previous.Count > 0)
|
if (Previous.Count > 0)
|
||||||
currentSectionPeak = currentStrain * strainDecay(offset - Previous[0].BaseObject.StartTime);
|
currentSectionPeak = GetPeakStrain(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the peak strain at a point in time.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="time">The time to retrieve the peak strain at.</param>
|
||||||
|
/// <returns>The peak strain.</returns>
|
||||||
|
protected virtual double GetPeakStrain(double time) => CurrentStrain * strainDecay(time - Previous[0].BaseObject.StartTime);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the calculated difficulty value representing all processed <see cref="DifficultyHitObject"/>s.
|
/// Returns the calculated difficulty value representing all processed <see cref="DifficultyHitObject"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user