Fix TimeRate not being considered for performance calculation

This commit is contained in:
smoogipoo
2018-05-14 11:15:14 +09:00
parent 9515eb4281
commit e1b8a1589b
3 changed files with 35 additions and 6 deletions

View File

@ -2,7 +2,11 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Timing;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Scoring
{
@ -14,6 +18,8 @@ namespace osu.Game.Rulesets.Scoring
protected readonly IBeatmap Beatmap;
protected readonly Score Score;
protected double TimeRate { get; private set; } = 1;
protected PerformanceCalculator(Ruleset ruleset, IBeatmap beatmap, Score score)
{
Score = score;
@ -22,6 +28,15 @@ namespace osu.Game.Rulesets.Scoring
var diffCalc = ruleset.CreateDifficultyCalculator(beatmap, score.Mods);
diffCalc.Calculate(attributes);
ApplyMods(score.Mods);
}
protected virtual void ApplyMods(Mod[] mods)
{
var clock = new StopwatchClock();
mods.OfType<IApplicableToClock>().ForEach(m => m.ApplyToClock(clock));
TimeRate = clock.Rate;
}
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);