mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 12:33:01 +08:00
Add timing distribution to OsuScoreProcessor
This commit is contained in:
parent
a7f8c5935d
commit
e98f51923a
@ -1,17 +1,93 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu.Judgements;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Scoring
|
||||
{
|
||||
public class OsuScoreProcessor : ScoreProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// The number of bins on each side of the timing distribution.
|
||||
/// </summary>
|
||||
private const int timing_distribution_bins = 25;
|
||||
|
||||
/// <summary>
|
||||
/// The total number of bins in the timing distribution, including bins on both sides and the centre bin at 0.
|
||||
/// </summary>
|
||||
private const int total_timing_distribution_bins = timing_distribution_bins * 2 + 1;
|
||||
|
||||
/// <summary>
|
||||
/// The centre bin, with a timing distribution very close to/at 0.
|
||||
/// </summary>
|
||||
private const int timing_distribution_centre_bin_index = timing_distribution_bins;
|
||||
|
||||
private TimingDistribution timingDistribution;
|
||||
|
||||
public override void ApplyBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
var hitWindows = CreateHitWindows();
|
||||
hitWindows.SetDifficulty(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty);
|
||||
|
||||
timingDistribution = new TimingDistribution(total_timing_distribution_bins, hitWindows.WindowFor(hitWindows.LowestSuccessfulHitResult()) / timing_distribution_bins);
|
||||
|
||||
base.ApplyBeatmap(beatmap);
|
||||
}
|
||||
|
||||
protected override void OnResultApplied(JudgementResult result)
|
||||
{
|
||||
base.OnResultApplied(result);
|
||||
|
||||
if (result.IsHit)
|
||||
{
|
||||
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
||||
timingDistribution.Bins[timing_distribution_centre_bin_index + binOffset]++;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnResultReverted(JudgementResult result)
|
||||
{
|
||||
base.OnResultReverted(result);
|
||||
|
||||
if (result.IsHit)
|
||||
{
|
||||
int binOffset = (int)(result.TimeOffset / timingDistribution.BinSize);
|
||||
timingDistribution.Bins[timing_distribution_centre_bin_index + binOffset]--;
|
||||
}
|
||||
}
|
||||
|
||||
public override void PopulateScore(ScoreInfo score)
|
||||
{
|
||||
base.PopulateScore(score);
|
||||
}
|
||||
|
||||
protected override void Reset(bool storeResults)
|
||||
{
|
||||
base.Reset(storeResults);
|
||||
|
||||
timingDistribution.Bins.AsSpan().Clear();
|
||||
}
|
||||
|
||||
protected override JudgementResult CreateResult(HitObject hitObject, Judgement judgement) => new OsuJudgementResult(hitObject, judgement);
|
||||
|
||||
public override HitWindows CreateHitWindows() => new OsuHitWindows();
|
||||
}
|
||||
|
||||
public class TimingDistribution
|
||||
{
|
||||
public readonly int[] Bins;
|
||||
public readonly double BinSize;
|
||||
|
||||
public TimingDistribution(int binCount, double binSize)
|
||||
{
|
||||
Bins = new int[binCount];
|
||||
BinSize = binSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,6 +129,12 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
updateScore();
|
||||
|
||||
OnResultApplied(result);
|
||||
}
|
||||
|
||||
protected virtual void OnResultApplied(JudgementResult result)
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override void RevertResultInternal(JudgementResult result)
|
||||
@ -154,6 +160,12 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
updateScore();
|
||||
|
||||
OnResultReverted(result);
|
||||
}
|
||||
|
||||
protected virtual void OnResultReverted(JudgementResult result)
|
||||
{
|
||||
}
|
||||
|
||||
private void updateScore()
|
||||
|
Loading…
Reference in New Issue
Block a user