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 osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Framework.Timing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps
|
|
|
|
|
{
|
|
|
|
|
public abstract class DifficultyCalculator
|
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
protected readonly IBeatmap Beatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected readonly Mod[] Mods;
|
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
|
protected double TimeRate = 1;
|
|
|
|
|
|
2018-04-19 19:44:38 +08:00
|
|
|
|
protected DifficultyCalculator(IBeatmap beatmap, Mod[] mods = null)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-04-19 21:04:12 +08:00
|
|
|
|
Beatmap = beatmap;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Mods = mods ?? new Mod[0];
|
|
|
|
|
|
|
|
|
|
ApplyMods(Mods);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void ApplyMods(Mod[] mods)
|
|
|
|
|
{
|
|
|
|
|
var clock = new StopwatchClock();
|
|
|
|
|
mods.OfType<IApplicableToClock>().ForEach(m => m.ApplyToClock(clock));
|
|
|
|
|
TimeRate = clock.Rate;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void PreprocessHitObjects()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 21:04:12 +08:00
|
|
|
|
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|