mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 03:53:21 +08:00
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>
This commit is contained in:
parent
e57565435e
commit
22e839d62b
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Beatmaps;
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
|
using osu.Game.Rulesets.Catch.Difficulty.Preprocessing;
|
||||||
@ -40,7 +41,7 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
|
|
||||||
CatchDifficultyAttributes attributes = new CatchDifficultyAttributes
|
CatchDifficultyAttributes attributes = new CatchDifficultyAttributes
|
||||||
{
|
{
|
||||||
StarRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier,
|
StarRating = Math.Sqrt(skills.OfType<Movement>().Single().DifficultyValue()) * difficulty_multiplier,
|
||||||
Mods = mods,
|
Mods = mods,
|
||||||
ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0,
|
ApproachRate = preempt > 1200.0 ? -(preempt - 1800.0) / 120.0 : -(preempt - 1200.0) / 150.0 + 5.0,
|
||||||
MaxCombo = beatmap.GetMaxCombo(),
|
MaxCombo = beatmap.GetMaxCombo(),
|
||||||
|
@ -48,7 +48,7 @@ namespace osu.Game.Rulesets.Mania.Difficulty
|
|||||||
|
|
||||||
ManiaDifficultyAttributes attributes = new ManiaDifficultyAttributes
|
ManiaDifficultyAttributes attributes = new ManiaDifficultyAttributes
|
||||||
{
|
{
|
||||||
StarRating = skills[0].DifficultyValue() * difficulty_multiplier,
|
StarRating = skills.OfType<Strain>().Single().DifficultyValue() * difficulty_multiplier,
|
||||||
Mods = mods,
|
Mods = mods,
|
||||||
// In osu-stable mania, rate-adjustment mods don't affect the hit window.
|
// In osu-stable mania, rate-adjustment mods don't affect the hit window.
|
||||||
// This is done the way it is to introduce fractional differences in order to match osu-stable for the time being.
|
// This is done the way it is to introduce fractional differences in order to match osu-stable for the time being.
|
||||||
|
@ -36,20 +36,22 @@ namespace osu.Game.Rulesets.Osu.Difficulty
|
|||||||
if (beatmap.HitObjects.Count == 0)
|
if (beatmap.HitObjects.Count == 0)
|
||||||
return new OsuDifficultyAttributes { Mods = mods };
|
return new OsuDifficultyAttributes { Mods = mods };
|
||||||
|
|
||||||
double aimRating = Math.Sqrt(skills[0].DifficultyValue()) * difficulty_multiplier;
|
var aim = skills.OfType<Aim>().Single(a => a.IncludeSliders);
|
||||||
double aimRatingNoSliders = Math.Sqrt(skills[1].DifficultyValue()) * difficulty_multiplier;
|
double aimRating = Math.Sqrt(aim.DifficultyValue()) * difficulty_multiplier;
|
||||||
double speedRating = Math.Sqrt(skills[2].DifficultyValue()) * difficulty_multiplier;
|
double aimDifficultyStrainCount = aim.CountTopWeightedStrains();
|
||||||
double speedNotes = ((Speed)skills[2]).RelevantNoteCount();
|
double difficultSliders = aim.GetDifficultSliders();
|
||||||
double difficultSliders = ((Aim)skills[0]).GetDifficultSliders();
|
|
||||||
double flashlightRating = 0.0;
|
|
||||||
|
|
||||||
if (mods.Any(h => h is OsuModFlashlight))
|
|
||||||
flashlightRating = Math.Sqrt(skills[3].DifficultyValue()) * difficulty_multiplier;
|
|
||||||
|
|
||||||
|
var aimWithoutSliders = skills.OfType<Aim>().Single(a => !a.IncludeSliders);
|
||||||
|
double aimRatingNoSliders = Math.Sqrt(aimWithoutSliders.DifficultyValue()) * difficulty_multiplier;
|
||||||
double sliderFactor = aimRating > 0 ? aimRatingNoSliders / aimRating : 1;
|
double sliderFactor = aimRating > 0 ? aimRatingNoSliders / aimRating : 1;
|
||||||
|
|
||||||
double aimDifficultyStrainCount = ((OsuStrainSkill)skills[0]).CountTopWeightedStrains();
|
var speed = skills.OfType<Speed>().Single();
|
||||||
double speedDifficultyStrainCount = ((OsuStrainSkill)skills[2]).CountTopWeightedStrains();
|
double speedRating = Math.Sqrt(speed.DifficultyValue()) * difficulty_multiplier;
|
||||||
|
double speedNotes = speed.RelevantNoteCount();
|
||||||
|
double speedDifficultyStrainCount = speed.CountTopWeightedStrains();
|
||||||
|
|
||||||
|
var flashlight = skills.OfType<Flashlight>().SingleOrDefault();
|
||||||
|
double flashlightRating = flashlight == null ? 0.0 : Math.Sqrt(flashlight.DifficultyValue()) * difficulty_multiplier;
|
||||||
|
|
||||||
if (mods.Any(m => m is OsuModTouchDevice))
|
if (mods.Any(m => m is OsuModTouchDevice))
|
||||||
{
|
{
|
||||||
|
@ -16,14 +16,14 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class Aim : OsuStrainSkill
|
public class Aim : OsuStrainSkill
|
||||||
{
|
{
|
||||||
public Aim(Mod[] mods, bool withSliders)
|
public readonly bool IncludeSliders;
|
||||||
|
|
||||||
|
public Aim(Mod[] mods, bool includeSliders)
|
||||||
: base(mods)
|
: base(mods)
|
||||||
{
|
{
|
||||||
this.withSliders = withSliders;
|
IncludeSliders = includeSliders;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly bool withSliders;
|
|
||||||
|
|
||||||
private double currentStrain;
|
private double currentStrain;
|
||||||
|
|
||||||
private double skillMultiplier => 25.6;
|
private double skillMultiplier => 25.6;
|
||||||
@ -38,7 +38,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Skills
|
|||||||
protected override double StrainValueAt(DifficultyHitObject current)
|
protected override double StrainValueAt(DifficultyHitObject current)
|
||||||
{
|
{
|
||||||
currentStrain *= strainDecay(current.DeltaTime);
|
currentStrain *= strainDecay(current.DeltaTime);
|
||||||
currentStrain += AimEvaluator.EvaluateDifficultyOf(current, withSliders) * skillMultiplier;
|
currentStrain += AimEvaluator.EvaluateDifficultyOf(current, IncludeSliders) * skillMultiplier;
|
||||||
|
|
||||||
if (current.BaseObject is Slider)
|
if (current.BaseObject is Slider)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
|||||||
private double skillMultiplier => 1.1;
|
private double skillMultiplier => 1.1;
|
||||||
private double strainDecayBase => 0.4;
|
private double strainDecayBase => 0.4;
|
||||||
|
|
||||||
private readonly bool singleColourStamina;
|
public readonly bool SingleColourStamina;
|
||||||
private readonly bool isConvert;
|
private readonly bool isConvert;
|
||||||
|
|
||||||
private double currentStrain;
|
private double currentStrain;
|
||||||
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
|||||||
public Stamina(Mod[] mods, bool singleColourStamina, bool isConvert)
|
public Stamina(Mod[] mods, bool singleColourStamina, bool isConvert)
|
||||||
: base(mods)
|
: base(mods)
|
||||||
{
|
{
|
||||||
this.singleColourStamina = singleColourStamina;
|
SingleColourStamina = singleColourStamina;
|
||||||
this.isConvert = isConvert;
|
this.isConvert = isConvert;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,12 +50,12 @@ namespace osu.Game.Rulesets.Taiko.Difficulty.Skills
|
|||||||
|
|
||||||
double monolengthBonus = isConvert ? 1 : 1 + Math.Min(Math.Max((index - 5) / 50.0, 0), 0.30);
|
double monolengthBonus = isConvert ? 1 : 1 + Math.Min(Math.Max((index - 5) / 50.0, 0), 0.30);
|
||||||
|
|
||||||
if (singleColourStamina)
|
if (SingleColourStamina)
|
||||||
return DifficultyCalculationUtils.Logistic(-(index - 10) / 2.0, currentStrain);
|
return DifficultyCalculationUtils.Logistic(-(index - 10) / 2.0, currentStrain);
|
||||||
|
|
||||||
return currentStrain * monolengthBonus;
|
return currentStrain * monolengthBonus;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override double CalculateInitialStrain(double time, DifficultyHitObject current) => singleColourStamina ? 0 : currentStrain * strainDecay(time - current.Previous(0).StartTime);
|
protected override double CalculateInitialStrain(double time, DifficultyHitObject current) => SingleColourStamina ? 0 : currentStrain * strainDecay(time - current.Previous(0).StartTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,11 +109,11 @@ namespace osu.Game.Rulesets.Taiko.Difficulty
|
|||||||
|
|
||||||
bool isRelax = mods.Any(h => h is TaikoModRelax);
|
bool isRelax = mods.Any(h => h is TaikoModRelax);
|
||||||
|
|
||||||
Rhythm rhythm = (Rhythm)skills.First(x => x is Rhythm);
|
var rhythm = skills.OfType<Rhythm>().Single();
|
||||||
Reading reading = (Reading)skills.First(x => x is Reading);
|
var reading = skills.OfType<Reading>().Single();
|
||||||
Colour colour = (Colour)skills.First(x => x is Colour);
|
var colour = skills.OfType<Colour>().Single();
|
||||||
Stamina stamina = (Stamina)skills.First(x => x is Stamina);
|
var stamina = skills.OfType<Stamina>().Single(s => !s.SingleColourStamina);
|
||||||
Stamina singleColourStamina = (Stamina)skills.Last(x => x is Stamina);
|
var singleColourStamina = skills.OfType<Stamina>().Single(s => s.SingleColourStamina);
|
||||||
|
|
||||||
double rhythmRating = rhythm.DifficultyValue() * rhythm_skill_multiplier;
|
double rhythmRating = rhythm.DifficultyValue() * rhythm_skill_multiplier;
|
||||||
double readingRating = reading.DifficultyValue() * reading_skill_multiplier;
|
double readingRating = reading.DifficultyValue() * reading_skill_multiplier;
|
||||||
|
Loading…
Reference in New Issue
Block a user