1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 01:03:02 +08:00
osu-lazer/osu.Game/Rulesets/Difficulty/PerformanceCalculator.cs

46 lines
1.4 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.Collections.Generic;
using System.Linq;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.IEnumerableExtensions;
2018-04-13 17:19:50 +08:00
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
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
2018-04-13 17:19:50 +08:00
{
public abstract class PerformanceCalculator
{
2018-06-14 15:04:48 +08:00
protected readonly DifficultyAttributes Attributes;
2018-04-13 17:19:50 +08:00
2018-05-16 00:43:58 +08:00
protected readonly Ruleset Ruleset;
protected readonly IBeatmap Beatmap;
2018-11-30 14:18:52 +08:00
protected readonly ScoreInfo Score;
2018-04-13 17:19:50 +08:00
protected double TimeRate { get; private set; } = 1;
2018-11-30 14:18:52 +08:00
protected PerformanceCalculator(Ruleset ruleset, WorkingBeatmap beatmap, ScoreInfo score)
2018-04-13 17:19:50 +08:00
{
2018-05-16 00:43:58 +08:00
Ruleset = ruleset;
2018-11-30 14:18:52 +08:00
Score = score;
2018-04-13 17:19:50 +08:00
2019-04-08 17:32:05 +08:00
Beatmap = beatmap.GetPlayableBeatmap(ruleset.RulesetInfo, score.Mods);
2018-06-14 15:04:48 +08:00
2018-11-30 14:18:52 +08:00
Attributes = ruleset.CreateDifficultyCalculator(beatmap).Calculate(score.Mods);
2018-11-30 14:18:52 +08:00
ApplyMods(score.Mods);
}
2018-05-14 10:52:22 +08:00
protected virtual void ApplyMods(Mod[] mods)
{
var track = new TrackVirtual(10000);
mods.OfType<IApplicableToTrack>().ForEach(m => m.ApplyToTrack(track));
TimeRate = track.Rate;
2018-04-13 17:19:50 +08:00
}
public abstract double Calculate(Dictionary<string, double> categoryDifficulty = null);
2018-04-13 17:19:50 +08:00
}
}