// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System.Threading; using System.Threading.Tasks; using osu.Game.Beatmaps; using osu.Game.Scoring; namespace osu.Game.Rulesets.Difficulty { public abstract class PerformanceCalculator { protected readonly Ruleset Ruleset; protected PerformanceCalculator(Ruleset ruleset) { Ruleset = ruleset; } public Task 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)); /// /// Creates to describe a score's performance. /// /// The score to create the attributes for. /// The difficulty attributes for the beatmap relating to the score. protected abstract PerformanceAttributes CreatePerformanceAttributes(ScoreInfo score, DifficultyAttributes attributes); } }