1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 16:07:25 +08:00
osu-lazer/osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs

47 lines
1.5 KiB
C#
Raw Normal View History

2018-04-13 17:19:50 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// 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;
2018-04-13 17:19:50 +08:00
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Difficulty
2018-04-13 17:19:50 +08:00
{
public abstract class PerformanceCalculator
{
private readonly Dictionary<string, double> attributes = new Dictionary<string, double>();
protected IDictionary<string, double> Attributes => attributes;
2018-05-16 00:43:58 +08:00
protected readonly Ruleset Ruleset;
protected readonly IBeatmap Beatmap;
2018-04-13 17:19:50 +08:00
protected readonly Score Score;
protected double TimeRate { get; private set; } = 1;
2018-04-19 19:44:38 +08:00
protected PerformanceCalculator(Ruleset ruleset, IBeatmap beatmap, Score score)
2018-04-13 17:19:50 +08:00
{
2018-05-16 00:43:58 +08:00
Ruleset = ruleset;
Beatmap = beatmap;
2018-05-16 00:43:58 +08:00
Score = score;
2018-04-13 17:19:50 +08:00
var diffCalc = ruleset.CreateDifficultyCalculator(beatmap, score.Mods);
diffCalc.Calculate(attributes);
ApplyMods(score.Mods);
}
2018-05-14 10:52:22 +08:00
protected virtual void ApplyMods(Mod[] mods)
{
var clock = new StopwatchClock();
mods.OfType<IApplicableToClock>().ForEach(m => m.ApplyToClock(clock));
TimeRate = clock.Rate;
2018-04-13 17:19:50 +08:00
}
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
2018-04-13 17:19:50 +08:00
}
}