1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-10 21:12:55 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Skills/Stamina.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
2.1 KiB
C#
Raw Normal View History

2020-05-11 13:50:02 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2024-10-31 06:57:47 +08:00
using System;
2020-05-11 13:50:02 +08:00
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Difficulty.Skills;
using osu.Game.Rulesets.Mods;
2022-06-06 12:42:49 +08:00
using osu.Game.Rulesets.Taiko.Difficulty.Evaluators;
2024-10-31 06:57:47 +08:00
using osu.Game.Rulesets.Taiko.Difficulty.Preprocessing;
2020-05-11 13:50:02 +08:00
namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
{
/// <summary>
/// Calculates the stamina coefficient of taiko difficulty.
/// </summary>
2024-10-31 06:57:47 +08:00
public class Stamina : StrainSkill
2020-05-11 13:50:02 +08:00
{
2024-10-31 06:57:47 +08:00
private double skillMultiplier => 1.1;
private double strainDecayBase => 0.4;
private readonly bool singleColourStamina;
2024-10-31 06:57:47 +08:00
private double currentStrain;
2020-05-11 13:50:02 +08:00
/// <summary>
/// Creates a <see cref="Stamina"/> skill.
/// </summary>
/// <param name="mods">Mods for use in skill calculations.</param>
/// <param name="singleColourStamina">Reads when Stamina is from a single coloured pattern.</param>
public Stamina(Mod[] mods, bool singleColourStamina)
: base(mods)
2020-05-11 13:50:02 +08:00
{
this.singleColourStamina = singleColourStamina;
2020-05-11 13:50:02 +08:00
}
2024-10-31 06:57:47 +08:00
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
protected override double StrainValueAt(DifficultyHitObject current)
2020-08-22 23:51:35 +08:00
{
2024-10-31 06:57:47 +08:00
currentStrain *= strainDecay(current.DeltaTime);
currentStrain += StaminaEvaluator.EvaluateDifficultyOf(current) * skillMultiplier;
// Safely prevents previous strains from shifting as new notes are added.
var currentObject = current as TaikoDifficultyHitObject;
int index = currentObject?.Colour.MonoStreak?.HitObjects.IndexOf(currentObject) ?? 0;
if (singleColourStamina)
return currentStrain / (1 + Math.Exp(-(index - 10) / 2.0));
2024-10-31 06:57:47 +08:00
return currentStrain;
2020-05-11 13:50:02 +08:00
}
2024-10-31 06:57:47 +08:00
protected override double CalculateInitialStrain(double time, DifficultyHitObject current) => singleColourStamina ? 0 : currentStrain * strainDecay(time - current.Previous(0).StartTime);
2020-05-11 13:50:02 +08:00
}
}