mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Allow GameplayRate to be nullable and assert before use
This commit is contained in:
parent
f5e1734de9
commit
a73c870712
@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Judgements
|
||||
/// <summary>
|
||||
/// The gameplay rate at the time this <see cref="JudgementResult"/> occurred.
|
||||
/// </summary>
|
||||
public double GameplayRate { get; internal set; }
|
||||
public double? GameplayRate { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// The combo prior to this <see cref="JudgementResult"/> occurring.
|
||||
|
@ -704,7 +704,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
}
|
||||
|
||||
Result.RawTime = Time.Current;
|
||||
Result.GameplayRate = (Clock as IGameplayClock)?.GetTrueGameplayRate() ?? 1.0;
|
||||
Result.GameplayRate = (Clock as IGameplayClock)?.GetTrueGameplayRate();
|
||||
|
||||
if (Result.HasResult)
|
||||
updateState(Result.IsHit ? ArmedState.Hit : ArmedState.Miss);
|
||||
|
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// <summary>
|
||||
/// The true gameplay rate at the time of the event.
|
||||
/// </summary>
|
||||
public readonly double GameplayRate;
|
||||
public readonly double? GameplayRate;
|
||||
|
||||
/// <summary>
|
||||
/// The hit result.
|
||||
@ -55,7 +55,7 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// <param name="hitObject">The <see cref="HitObject"/> that triggered the event.</param>
|
||||
/// <param name="lastHitObject">The previous <see cref="HitObject"/>.</param>
|
||||
/// <param name="position">A position corresponding to the event.</param>
|
||||
public HitEvent(double timeOffset, double gameplayRate, HitResult result, HitObject hitObject, [CanBeNull] HitObject lastHitObject, [CanBeNull] Vector2? position)
|
||||
public HitEvent(double timeOffset, double? gameplayRate, HitResult result, HitObject hitObject, [CanBeNull] HitObject lastHitObject, [CanBeNull] Vector2? position)
|
||||
{
|
||||
TimeOffset = timeOffset;
|
||||
GameplayRate = gameplayRate;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
namespace osu.Game.Rulesets.Scoring
|
||||
@ -18,8 +19,10 @@ namespace osu.Game.Rulesets.Scoring
|
||||
/// </returns>
|
||||
public static double? CalculateUnstableRate(this IEnumerable<HitEvent> hitEvents)
|
||||
{
|
||||
Debug.Assert(!hitEvents.Any(ev => ev.GameplayRate == null));
|
||||
|
||||
// Division by gameplay rate is to account for TimeOffset scaling with gameplay rate.
|
||||
double[] timeOffsets = hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset / ev.GameplayRate).ToArray();
|
||||
double[] timeOffsets = hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset / ev.GameplayRate!.Value).ToArray();
|
||||
return 10 * standardDeviation(timeOffsets);
|
||||
}
|
||||
|
||||
|
@ -473,7 +473,7 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
private void onNewResult(DrawableHitObject drawable, JudgementResult result)
|
||||
{
|
||||
Debug.Assert(result != null && drawable.Entry?.Result == result && result.RawTime != null && result.GameplayRate != 0.0);
|
||||
Debug.Assert(result != null && drawable.Entry?.Result == result && result.RawTime != null && result.GameplayRate != null);
|
||||
judgedEntries.Push(drawable.Entry.AsNonNull());
|
||||
|
||||
NewResult?.Invoke(drawable, result);
|
||||
|
Loading…
Reference in New Issue
Block a user