1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-31 14:25:10 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Difficulty/Skills/Aim.cs
StanR 22e839d62b
Replace indexed skill access with skills.OfType<...>().Single() (#30034)
* Replace indexed skill access with `skills.First(s is ...)`

* Fix comment

* Further refactoring to remove casts

---------

Co-authored-by: Dan Balasescu <smoogipoo@smgi.me>
Co-authored-by: Bartłomiej Dach <dach.bartlomiej@gmail.com>
2025-01-20 09:39:35 +00:00

66 lines
2.1 KiB
C#

// 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.
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Rulesets.Difficulty.Preprocessing;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Difficulty.Evaluators;
using osu.Game.Rulesets.Osu.Objects;
namespace osu.Game.Rulesets.Osu.Difficulty.Skills
{
/// <summary>
/// Represents the skill required to correctly aim at every object in the map with a uniform CircleSize and normalized distances.
/// </summary>
public class Aim : OsuStrainSkill
{
public readonly bool IncludeSliders;
public Aim(Mod[] mods, bool includeSliders)
: base(mods)
{
IncludeSliders = includeSliders;
}
private double currentStrain;
private double skillMultiplier => 25.6;
private double strainDecayBase => 0.15;
private readonly List<double> sliderStrains = new List<double>();
private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000);
protected override double CalculateInitialStrain(double time, DifficultyHitObject current) => currentStrain * strainDecay(time - current.Previous(0).StartTime);
protected override double StrainValueAt(DifficultyHitObject current)
{
currentStrain *= strainDecay(current.DeltaTime);
currentStrain += AimEvaluator.EvaluateDifficultyOf(current, IncludeSliders) * skillMultiplier;
if (current.BaseObject is Slider)
{
sliderStrains.Add(currentStrain);
}
return currentStrain;
}
public double GetDifficultSliders()
{
if (sliderStrains.Count == 0)
return 0;
double[] sortedStrains = sliderStrains.OrderDescending().ToArray();
double maxSliderStrain = sortedStrains.Max();
if (maxSliderStrain == 0)
return 0;
return sortedStrains.Sum(strain => 1.0 / (1.0 + Math.Exp(-(strain / maxSliderStrain * 12.0 - 6.0))));
}
}
}