diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs index 5da3613e8d..d8d48f8734 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/OsuDifficultyCalculator.cs @@ -30,7 +30,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty protected override double CalculateInternal(Dictionary categoryDifficulty) { OsuDifficultyBeatmap beatmap = new OsuDifficultyBeatmap(Objects); - Skill[] skills = new Skill[2] + Skill[] skills = new Skill[] { new Aim(), new Speed() diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyBeatmap.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyBeatmap.cs index a831320f4b..c2446409c5 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyBeatmap.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyBeatmap.cs @@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing { public class OsuDifficultyBeatmap : IEnumerable { - IEnumerator difficultyObjects; - private Queue onScreen = new Queue(); + private readonly IEnumerator difficultyObjects; + private readonly Queue onScreen = new Queue(); public OsuDifficultyBeatmap(List objects) { @@ -40,14 +40,14 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing foreach (OsuDifficultyHitObject h in onScreen) { - h.MSUntilHit -= latest.MS; + h.MsUntilHit -= latest.Ms; // Calculate reading strain here } onScreen.Enqueue(latest); } } - while (onScreen.Peek().MSUntilHit > 0 && hasNext); // Keep adding new notes on screen while there is still time before we have to hit the next one. + while (onScreen.Peek().MsUntilHit > 0 && hasNext); // Keep adding new notes on screen while there is still time before we have to hit the next one. yield return onScreen.Dequeue(); // Remove and return notes one by one that had to be hit before the latest note appeared. } @@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); - IEnumerator createDifficultyObjectEnumerator(List objects) + private IEnumerator createDifficultyObjectEnumerator(List objects) { // We will process HitObjects in groups of three to form a triangle, so we can calculate an angle for each note. OsuHitObject[] triangle = new OsuHitObject[3]; diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs index ca10b19fc1..4497f96c89 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Preprocessing/OsuDifficultyHitObject.cs @@ -18,13 +18,13 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing /// /// Milliseconds elapsed since the StartTime of the previous note. /// - public double MS { get; private set; } + public double Ms { get; private set; } - public double MSUntilHit { get; set; } + public double MsUntilHit { get; set; } private const int normalized_radius = 52; - private OsuHitObject[] t; + private readonly OsuHitObject[] t; public OsuDifficultyHitObject(OsuHitObject[] triangle) { @@ -51,8 +51,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Preprocessing private void setTimingValues() { // Every timing inverval is hard capped at the equivalent of 375 BPM streaming speed as a safety measure. - MS = Math.Max(40, t[0].StartTime - t[1].StartTime); - MSUntilHit = 450; // BaseObject.PreEmpt; + Ms = Math.Max(40, t[0].StartTime - t[1].StartTime); + MsUntilHit = 450; // BaseObject.PreEmpt; } } } diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Aim.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Aim.cs index 274e50ab2d..57fcff965a 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Aim.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Aim.cs @@ -7,9 +7,9 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills { public class Aim : Skill { - protected override double skillMultiplier => 26.25; - protected override double strainDecayBase => 0.15; + protected override double SkillMultiplier => 26.25; + protected override double StrainDecayBase => 0.15; - protected override double strainValue() => Math.Pow(current.Distance, 0.99) / current.MS; + protected override double StrainValue() => Math.Pow(Current.Distance, 0.99) / Current.Ms; } } diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Skill.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Skill.cs index 2146ffc4e6..c2aa55d650 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Skill.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Skill.cs @@ -11,30 +11,30 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills { public abstract class Skill { - protected abstract double skillMultiplier { get; } - protected abstract double strainDecayBase { get; } + protected abstract double SkillMultiplier { get; } + protected abstract double StrainDecayBase { get; } - protected OsuDifficultyHitObject current; - protected History previous = new History(2); // Contained objects not used yet + protected OsuDifficultyHitObject Current; + protected History Previous = new History(2); // Contained objects not used yet private double currentStrain = 1; // We keep track of the strain level at all times throughout the beatmap. private double currentSectionPeak = 1; // We also keep track of the peak strain level in the current section. - private List strainPeaks = new List(); + private readonly List strainPeaks = new List(); /// /// Process a HitObject and update current strain values accordingly. /// public void Process(OsuDifficultyHitObject h) { - current = h; + Current = h; - currentStrain *= strainDecay(current.MS); - if (!(current.BaseObject is Spinner)) - currentStrain += strainValue() * skillMultiplier; + currentStrain *= strainDecay(Current.Ms); + if (!(Current.BaseObject is Spinner)) + currentStrain += StrainValue() * SkillMultiplier; currentSectionPeak = Math.Max(currentStrain, currentSectionPeak); - previous.Push(current); + Previous.Push(Current); } /// @@ -42,7 +42,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills /// public void SaveCurrentPeak() { - if (previous.Count > 0) + if (Previous.Count > 0) strainPeaks.Add(currentSectionPeak); } @@ -54,8 +54,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills { // 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. - if (previous.Count > 0) - currentSectionPeak = currentStrain * strainDecay(offset - previous[0].BaseObject.StartTime); + if (Previous.Count > 0) + currentSectionPeak = currentStrain * strainDecay(offset - Previous[0].BaseObject.StartTime); } /// @@ -78,8 +78,8 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills return difficulty; } - protected abstract double strainValue(); + protected abstract double StrainValue(); - private double strainDecay(double ms) => Math.Pow(strainDecayBase, ms / 1000); + private double strainDecay(double ms) => Math.Pow(StrainDecayBase, ms / 1000); } } diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Speed.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Speed.cs index 42da6b8ed2..33e8fec829 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Speed.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Skills/Speed.cs @@ -5,16 +5,16 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills { public class Speed : Skill { - protected override double skillMultiplier => 1400; - protected override double strainDecayBase => 0.3; + protected override double SkillMultiplier => 1400; + protected override double StrainDecayBase => 0.3; private const double single_spacing_threshold = 125; private const double stream_spacing_threshold = 110; private const double almost_diameter = 90; - protected override double strainValue() + protected override double StrainValue() { - double distance = current.Distance; + double distance = Current.Distance; double speedValue; if (distance > single_spacing_threshold) @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Skills else speedValue = 0.95; - return speedValue / current.MS; + return speedValue / Current.Ms; } } } \ No newline at end of file diff --git a/osu.Game.Rulesets.Osu/OsuDifficulty/Utils/History.cs b/osu.Game.Rulesets.Osu/OsuDifficulty/Utils/History.cs index 4bf20b1830..38727707d9 100644 --- a/osu.Game.Rulesets.Osu/OsuDifficulty/Utils/History.cs +++ b/osu.Game.Rulesets.Osu/OsuDifficulty/Utils/History.cs @@ -13,10 +13,10 @@ namespace osu.Game.Rulesets.Osu.OsuDifficulty.Utils /// public class History : IEnumerable { - public int Count { get; private set; } = 0; + public int Count { get; private set; } - private T[] array; - private int size; + private readonly T[] array; + private readonly int size; private int marker; // Marks the position of the most recently added item. public History(int size)