1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 04:47:24 +08:00
osu-lazer/osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.5 KiB
C#
Raw Normal View History

// 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 17:19:50 +08:00
using System.Threading;
using System.Threading.Tasks;
using osu.Game.Beatmaps;
2018-11-28 15:12:57 +08:00
using osu.Game.Scoring;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Difficulty
{
public abstract class PerformanceCalculator
{
2018-05-16 00:43:58 +08:00
protected readonly Ruleset Ruleset;
protected PerformanceCalculator(Ruleset ruleset)
{
2018-05-16 00:43:58 +08:00
Ruleset = ruleset;
}
2018-05-14 10:52:22 +08:00
public Task<PerformanceAttributes> CalculateAsync(ScoreInfo score, DifficultyAttributes attributes, CancellationToken cancellationToken)
=> Task.Run(() => CreatePerformanceAttributes(score, attributes), cancellationToken);
public PerformanceAttributes Calculate(ScoreInfo score, DifficultyAttributes attributes)
=> CreatePerformanceAttributes(score, attributes);
public PerformanceAttributes Calculate(ScoreInfo score, IWorkingBeatmap beatmap)
=> Calculate(score, Ruleset.CreateDifficultyCalculator(beatmap).Calculate(score.Mods));
2018-04-13 17:19:50 +08:00
/// <summary>
/// Creates <see cref="PerformanceAttributes"/> to describe a score's performance.
/// </summary>
/// <param name="score">The score to create the attributes for.</param>
/// <param name="attributes">The difficulty attributes for the beatmap relating to the score.</param>
protected abstract PerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, DifficultyAttributes attributes);
}
}