mirror of
https://github.com/ppy/osu.git
synced 2025-01-10 01:53:09 +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.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Scoring
|
namespace osu.Game.Rulesets.Scoring
|
||||||
{
|
{
|
||||||
@ -69,7 +70,8 @@ namespace osu.Game.Rulesets.Scoring
|
|||||||
return timeOffsets.Average();
|
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
|
public class UnstableRateCalculationResult
|
||||||
{
|
{
|
||||||
|
@ -28,6 +28,8 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private const float alpha_when_invalid = 0.3f;
|
private const float alpha_when_invalid = 0.3f;
|
||||||
private readonly Bindable<bool> valid = new Bindable<bool>();
|
private readonly Bindable<bool> valid = new Bindable<bool>();
|
||||||
|
|
||||||
|
private HitEventExtensions.UnstableRateCalculationResult? unstableRateResult;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private ScoreProcessor scoreProcessor { get; set; } = null!;
|
private ScoreProcessor scoreProcessor { get; set; } = null!;
|
||||||
|
|
||||||
@ -53,13 +55,20 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
updateDisplay();
|
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()
|
private void updateDisplay()
|
||||||
{
|
{
|
||||||
double? unstableRate = scoreProcessor.HitEvents.CalculateUnstableRate()?.Result;
|
unstableRateResult = scoreProcessor.HitEvents.CalculateUnstableRate(unstableRateResult);
|
||||||
|
|
||||||
|
double? unstableRate = unstableRateResult?.Result;
|
||||||
|
|
||||||
valid.Value = unstableRate != null;
|
valid.Value = unstableRate != null;
|
||||||
|
|
||||||
if (unstableRate != null)
|
if (unstableRate != null)
|
||||||
Current.Value = (int)Math.Round(unstableRate.Value);
|
Current.Value = (int)Math.Round(unstableRate.Value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user