mirror of
https://github.com/ppy/osu.git
synced 2025-01-08 21:22:56 +08:00
Only update unstable rate counter when an applicable hitobject is reached
This commit is contained in:
parent
ea68d4b33a
commit
bbe8f2ec44
@ -5,6 +5,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
@ -69,7 +70,8 @@ namespace osu.Game.Rulesets.Scoring
|
||||
return timeOffsets.Average();
|
||||
}
|
||||
|
||||
public static bool AffectsUnstableRate(HitEvent e) => e.HitObject.HitWindows != HitWindows.Empty && e.Result.IsHit();
|
||||
public static bool AffectsUnstableRate(HitEvent e) => AffectsUnstableRate(e.HitObject, e.Result);
|
||||
public static bool AffectsUnstableRate(HitObject hitObject, HitResult result) => hitObject.HitWindows != HitWindows.Empty && result.IsHit();
|
||||
|
||||
public class UnstableRateCalculationResult
|
||||
{
|
||||
|
@ -28,6 +28,8 @@ namespace osu.Game.Screens.Play.HUD
|
||||
private const float alpha_when_invalid = 0.3f;
|
||||
private readonly Bindable<bool> valid = new Bindable<bool>();
|
||||
|
||||
private HitEventExtensions.UnstableRateCalculationResult? unstableRateResult;
|
||||
|
||||
[Resolved]
|
||||
private ScoreProcessor scoreProcessor { get; set; } = null!;
|
||||
|
||||
@ -53,13 +55,20 @@ namespace osu.Game.Screens.Play.HUD
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
private void updateDisplay(JudgementResult _) => Scheduler.AddOnce(updateDisplay);
|
||||
private void updateDisplay(JudgementResult result)
|
||||
{
|
||||
if (HitEventExtensions.AffectsUnstableRate(result.HitObject, result.Type))
|
||||
Scheduler.AddOnce(updateDisplay);
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
double? unstableRate = scoreProcessor.HitEvents.CalculateUnstableRate()?.Result;
|
||||
unstableRateResult = scoreProcessor.HitEvents.CalculateUnstableRate(unstableRateResult);
|
||||
|
||||
double? unstableRate = unstableRateResult?.Result;
|
||||
|
||||
valid.Value = unstableRate != null;
|
||||
|
||||
if (unstableRate != null)
|
||||
Current.Value = (int)Math.Round(unstableRate.Value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user