2023-06-23 00:37:25 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 16:43:03 +08:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2024-01-29 14:15:10 +08:00
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
2022-03-14 13:25:26 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-11-28 15:12:57 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-05-15 16:38:04 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Difficulty
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public abstract class PerformanceCalculator
|
|
|
|
|
{
|
2018-05-16 00:43:58 +08:00
|
|
|
|
protected readonly Ruleset Ruleset;
|
2018-05-14 10:15:14 +08:00
|
|
|
|
|
2022-03-14 13:25:26 +08:00
|
|
|
|
protected PerformanceCalculator(Ruleset ruleset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-05-16 00:43:58 +08:00
|
|
|
|
Ruleset = ruleset;
|
2018-05-14 10:15:14 +08:00
|
|
|
|
}
|
2018-05-14 10:52:22 +08:00
|
|
|
|
|
2024-01-29 14:15:10 +08:00
|
|
|
|
public Task<PerformanceAttributes> CalculateAsync(ScoreInfo score, DifficultyAttributes attributes, CancellationToken cancellationToken)
|
|
|
|
|
=> Task.Run(() => CreatePerformanceAttributes(score, attributes), cancellationToken);
|
|
|
|
|
|
2022-03-14 13:25:26 +08:00
|
|
|
|
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
|
|
|
|
|
2022-03-14 13:25:26 +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);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|