diff --git a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObjectDifficulty.cs b/osu.Game.Rulesets.Taiko/Objects/TaikoHitObjectDifficulty.cs index 5056a52346..c8bb73abbb 100644 --- a/osu.Game.Rulesets.Taiko/Objects/TaikoHitObjectDifficulty.cs +++ b/osu.Game.Rulesets.Taiko/Objects/TaikoHitObjectDifficulty.cs @@ -27,14 +27,14 @@ internal class TaikoHitObjectDifficulty /// internal double Strain = 1; - private double timeElapsed = 0; + private double timeElapsed; private int sameTypeSince = 1; private bool isRim => BaseHitObject is RimHit; public TaikoHitObjectDifficulty(TaikoHitObject baseHitObject) { - this.BaseHitObject = baseHitObject; + BaseHitObject = baseHitObject; } internal void CalculateStrains(TaikoHitObjectDifficulty previousHitObject, double timeRate) diff --git a/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs b/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs index f80c777f05..33e9510f1c 100644 --- a/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Taiko/TaikoDifficultyCalculator.cs @@ -30,7 +30,7 @@ internal class TaikoDifficultyCalculator : DifficultyCalculator /// /// HitObjects are stored as a member variable. /// - private List difficultyHitObjects = new List(); + private readonly List difficultyHitObjects = new List(); public TaikoDifficultyCalculator(Beatmap beatmap) : base(beatmap) @@ -64,22 +64,22 @@ protected override double CalculateInternal(Dictionary categoryD private bool calculateStrainValues() { // Traverse hitObjects in pairs to calculate the strain value of NextHitObject from the strain value of CurrentHitObject and environment. - List.Enumerator hitObjectsEnumerator = difficultyHitObjects.GetEnumerator(); - - if (!hitObjectsEnumerator.MoveNext()) return false; - - TaikoHitObjectDifficulty currentHitObject = hitObjectsEnumerator.Current; - TaikoHitObjectDifficulty nextHitObject; - - // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. - while (hitObjectsEnumerator.MoveNext()) + using (List.Enumerator hitObjectsEnumerator = difficultyHitObjects.GetEnumerator()) { - nextHitObject = hitObjectsEnumerator.Current; - nextHitObject.CalculateStrains(currentHitObject, TimeRate); - currentHitObject = nextHitObject; - } + if (!hitObjectsEnumerator.MoveNext()) return false; - return true; + TaikoHitObjectDifficulty current = hitObjectsEnumerator.Current; + + // First hitObject starts at strain 1. 1 is the default for strain values, so we don't need to set it here. See DifficultyHitObject. + while (hitObjectsEnumerator.MoveNext()) + { + var next = hitObjectsEnumerator.Current; + next?.CalculateStrains(current, TimeRate); + current = next; + } + + return true; + } } private double calculateDifficulty()