2019-01-24 08:43:03 +00:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-10-02 17:24:30 +00:00
|
|
|
using System;
|
2018-04-13 09:19:50 +00:00
|
|
|
using System.Collections.Generic;
|
2018-05-14 02:15:14 +00:00
|
|
|
using System.Linq;
|
2019-12-09 08:34:04 +00:00
|
|
|
using osu.Framework.Audio.Track;
|
2018-05-14 02:15:14 +00:00
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2018-11-28 07:12:57 +00:00
|
|
|
using osu.Game.Scoring;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-05-15 08:38:04 +00:00
|
|
|
namespace osu.Game.Rulesets.Difficulty
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
|
|
|
public abstract class PerformanceCalculator
|
|
|
|
{
|
2018-06-14 07:04:48 +00:00
|
|
|
protected readonly DifficultyAttributes Attributes;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-05-15 16:43:58 +00:00
|
|
|
protected readonly Ruleset Ruleset;
|
2018-11-30 06:18:52 +00:00
|
|
|
protected readonly ScoreInfo Score;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2018-05-14 02:15:14 +00:00
|
|
|
protected double TimeRate { get; private set; } = 1;
|
|
|
|
|
2020-10-02 17:24:30 +00:00
|
|
|
protected PerformanceCalculator(Ruleset ruleset, DifficultyAttributes attributes, ScoreInfo score)
|
2018-04-13 09:19:50 +00:00
|
|
|
{
|
2018-05-15 16:43:58 +00:00
|
|
|
Ruleset = ruleset;
|
2018-11-30 06:18:52 +00:00
|
|
|
Score = score;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
2020-10-02 17:24:30 +00:00
|
|
|
Attributes = attributes ?? throw new ArgumentNullException(nameof(attributes));
|
2018-05-14 02:15:14 +00:00
|
|
|
|
2018-11-30 06:18:52 +00:00
|
|
|
ApplyMods(score.Mods);
|
2018-05-14 02:15:14 +00:00
|
|
|
}
|
2018-05-14 02:52:22 +00:00
|
|
|
|
2018-05-14 02:15:14 +00:00
|
|
|
protected virtual void ApplyMods(Mod[] mods)
|
|
|
|
{
|
2019-12-09 08:34:04 +00:00
|
|
|
var track = new TrackVirtual(10000);
|
|
|
|
mods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
|
|
|
|
TimeRate = track.Rate;
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
|
2018-04-19 13:04:12 +00:00
|
|
|
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
|
2018-04-13 09:19:50 +00:00
|
|
|
}
|
|
|
|
}
|