Make lastJudgedHitObject nullable, and fix typo in name.

This commit is contained in:
mk56-spn 2023-02-14 10:12:37 +01:00
parent 6ff6e06a69
commit d100a4a491

View File

@ -2,8 +2,10 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Diagnostics;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -48,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Mods
private readonly DrawablePool<BubbleDrawable> bubblePool = new DrawablePool<BubbleDrawable>(100); private readonly DrawablePool<BubbleDrawable> bubblePool = new DrawablePool<BubbleDrawable>(100);
private DrawableOsuHitObject lastJudgedHitobject = null!; private DrawableOsuHitObject? lastJudgedHitObject;
public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank; public ScoreRank AdjustRank(ScoreRank rank, double accuracy) => rank;
@ -60,9 +62,11 @@ namespace osu.Game.Rulesets.Osu.Mods
scoreProcessor.NewJudgement += result => scoreProcessor.NewJudgement += result =>
{ {
if (result.HitObject is not OsuHitObject osuHitObject) return; if (result.HitObject is not OsuHitObject osuHitObject || lastJudgedHitObject.IsNull()) return;
DrawableOsuHitObject drawableOsuHitObject = lastJudgedHitobject; Debug.Assert(result.HitObject == lastJudgedHitObject.HitObject);
DrawableOsuHitObject drawableOsuHitObject = lastJudgedHitObject;
switch (result.HitObject) switch (result.HitObject)
{ {
@ -144,18 +148,9 @@ namespace osu.Game.Rulesets.Osu.Mods
applySliderState(slider); applySliderState(slider);
} }
if (osuHitObject == lastJudgedHitobject || !osuHitObject.Judged) return; if (osuHitObject == lastJudgedHitObject || !osuHitObject.Judged) return;
switch (osuHitObject) lastJudgedHitObject = osuHitObject;
{
case DrawableSlider:
case DrawableSpinnerTick:
break;
default:
lastJudgedHitobject = osuHitObject;
break;
}
} }
// Makes the slider border coloured on all skins (for aesthetics) // Makes the slider border coloured on all skins (for aesthetics)