From 2a4994e5cedc64ae7bf5d7d49b7e9573557af6c5 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 3 Aug 2018 15:38:48 +0900 Subject: [PATCH] Make hitobjects only have one judgement + result --- osu.Game.Rulesets.Catch/Objects/Banana.cs | 3 +- .../Drawable/DrawableCatchHitObject.cs | 5 +- osu.Game.Rulesets.Catch/Objects/Droplet.cs | 3 +- osu.Game.Rulesets.Catch/Objects/Fruit.cs | 3 +- .../Objects/TinyDroplet.cs | 3 +- .../Objects/Drawables/DrawableHoldNote.cs | 8 +-- .../Objects/Drawables/DrawableHoldNoteTick.cs | 5 +- .../Objects/Drawables/DrawableNote.cs | 5 +- osu.Game.Rulesets.Mania/Objects/HoldNote.cs | 3 +- .../Objects/HoldNoteTick.cs | 3 +- osu.Game.Rulesets.Mania/Objects/Note.cs | 3 +- osu.Game.Rulesets.Mania/Objects/TailNote.cs | 3 +- .../TestCaseHitCircle.cs | 2 +- .../Objects/Drawables/DrawableHitCircle.cs | 5 +- .../Objects/Drawables/DrawableOsuHitObject.cs | 3 +- .../Objects/Drawables/DrawableRepeatPoint.cs | 3 +- .../Objects/Drawables/DrawableSlider.cs | 6 +- .../Objects/Drawables/DrawableSliderTail.cs | 3 +- .../Objects/Drawables/DrawableSliderTick.cs | 3 +- .../Objects/Drawables/DrawableSpinner.cs | 2 +- osu.Game.Rulesets.Osu/Objects/HitCircle.cs | 3 +- osu.Game.Rulesets.Osu/Objects/RepeatPoint.cs | 3 +- osu.Game.Rulesets.Osu/Objects/Slider.cs | 2 +- .../Objects/SliderTailCircle.cs | 3 +- osu.Game.Rulesets.Osu/Objects/SliderTick.cs | 3 +- osu.Game.Rulesets.Osu/Objects/Spinner.cs | 3 +- .../Objects/Drawables/DrawableHitObject.cs | 64 +++++++------------ osu.Game/Rulesets/Objects/HitObject.cs | 9 +-- osu.Game/Rulesets/Scoring/ScoreProcessor.cs | 12 ++-- 29 files changed, 66 insertions(+), 110 deletions(-) diff --git a/osu.Game.Rulesets.Catch/Objects/Banana.cs b/osu.Game.Rulesets.Catch/Objects/Banana.cs index 1b84869172..e021bafdb6 100644 --- a/osu.Game.Rulesets.Catch/Objects/Banana.cs +++ b/osu.Game.Rulesets.Catch/Objects/Banana.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Judgements; @@ -11,6 +10,6 @@ namespace osu.Game.Rulesets.Catch.Objects { public override FruitVisualRepresentation VisualRepresentation => FruitVisualRepresentation.Banana; - protected override IEnumerable CreateJudgements() => new[] { new CatchBananaJudgement() }; + protected override Judgement CreateJudgement() => new CatchBananaJudgement(); } } diff --git a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs index 019a4779ac..982fa193c6 100644 --- a/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs +++ b/osu.Game.Rulesets.Catch/Objects/Drawable/DrawableCatchHitObject.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics; @@ -57,8 +56,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable { if (CheckPosition == null) return; - if (timeOffset >= 0 && Results.Count > 0) - ApplyResult(Results.Single(), r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss); + if (timeOffset >= 0 && Result != null) + ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss); } protected override void SkinChanged(ISkinSource skin, bool allowFallback) diff --git a/osu.Game.Rulesets.Catch/Objects/Droplet.cs b/osu.Game.Rulesets.Catch/Objects/Droplet.cs index a6e7d29305..79aefdb6d3 100644 --- a/osu.Game.Rulesets.Catch/Objects/Droplet.cs +++ b/osu.Game.Rulesets.Catch/Objects/Droplet.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Judgements; @@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Catch.Objects { public class Droplet : CatchHitObject { - protected override IEnumerable CreateJudgements() => new[] { new CatchDropletJudgement() }; + protected override Judgement CreateJudgement() => new CatchDropletJudgement(); } } diff --git a/osu.Game.Rulesets.Catch/Objects/Fruit.cs b/osu.Game.Rulesets.Catch/Objects/Fruit.cs index fd9cd13beb..53a484ed56 100644 --- a/osu.Game.Rulesets.Catch/Objects/Fruit.cs +++ b/osu.Game.Rulesets.Catch/Objects/Fruit.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Judgements; @@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Catch.Objects { public class Fruit : CatchHitObject { - protected override IEnumerable CreateJudgements() => new[] { new CatchJudgement() }; + protected override Judgement CreateJudgement() => new CatchJudgement(); } } diff --git a/osu.Game.Rulesets.Catch/Objects/TinyDroplet.cs b/osu.Game.Rulesets.Catch/Objects/TinyDroplet.cs index 069d3be5c0..ddb88c2c1c 100644 --- a/osu.Game.Rulesets.Catch/Objects/TinyDroplet.cs +++ b/osu.Game.Rulesets.Catch/Objects/TinyDroplet.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Catch.Judgements; using osu.Game.Rulesets.Judgements; @@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Catch.Objects { public class TinyDroplet : Droplet { - protected override IEnumerable CreateJudgements() => new[] { new CatchTinyDropletJudgement() }; + protected override Judgement CreateJudgement() => new CatchTinyDropletJudgement(); } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs index a3a81245a2..da4bf1c575 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNote.cs @@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (tail.AllJudged) - ApplyResult(Results.Single(), r => r.Type = HitResult.Perfect); + ApplyResult(r => r.Type = HitResult.Perfect); } protected override void Update() @@ -165,7 +165,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables return false; // If the key has been released too early, the user should not receive full score for the release - if (Results.Single().Type == HitResult.Miss) + if (Result.Type == HitResult.Miss) holdNote.hasBroken = true; // The head note also handles early hits before the body, but we want accurate early hits to count as the body being held @@ -204,7 +204,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (!userTriggered) { if (!HitObject.HitWindows.CanBeHit(timeOffset)) - ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); + ApplyResult(r => r.Type = HitResult.Miss); return; } @@ -213,7 +213,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (result == HitResult.None) return; - ApplyResult(Results.Single(), r => + ApplyResult(r => { if (holdNote.hasBroken && (result == HitResult.Perfect || result == HitResult.Perfect)) result = HitResult.Good; diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs index 6f718ef5ab..05a4ea60d6 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableHoldNoteTick.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Linq; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; @@ -80,9 +79,9 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables var startTime = HoldStartTime?.Invoke(); if (startTime == null || startTime > HitObject.StartTime) - ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); + ApplyResult(r => r.Type = HitResult.Miss); else - ApplyResult(Results.Single(), r => r.Type = HitResult.Perfect); + ApplyResult(r => r.Type = HitResult.Perfect); } } } diff --git a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs index ad4969207d..42b4128019 100644 --- a/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/Drawables/DrawableNote.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using osu.Framework.Extensions.Color4Extensions; using OpenTK.Graphics; using osu.Framework.Graphics; @@ -61,7 +60,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (!userTriggered) { if (!HitObject.HitWindows.CanBeHit(timeOffset)) - ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); + ApplyResult(r => r.Type = HitResult.Miss); return; } @@ -69,7 +68,7 @@ namespace osu.Game.Rulesets.Mania.Objects.Drawables if (result == HitResult.None) return; - ApplyResult(Results.Single(), r => r.Type = result); + ApplyResult(r => r.Type = result); } public virtual bool OnPressed(ManiaAction action) diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs index 8a22ff1bf6..26116c2691 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNote.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Judgements; @@ -98,6 +97,6 @@ namespace osu.Game.Rulesets.Mania.Objects } } - protected override IEnumerable CreateJudgements() => new[] { new HoldNoteJudgement() }; + protected override Judgement CreateJudgement() => new HoldNoteJudgement(); } } diff --git a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs index 9056310cf2..b428c6158d 100644 --- a/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs +++ b/osu.Game.Rulesets.Mania/Objects/HoldNoteTick.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Judgements; @@ -12,6 +11,6 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class HoldNoteTick : ManiaHitObject { - protected override IEnumerable CreateJudgements() => new[] { new HoldNoteTickJudgement() }; + protected override Judgement CreateJudgement() => new HoldNoteTickJudgement(); } } diff --git a/osu.Game.Rulesets.Mania/Objects/Note.cs b/osu.Game.Rulesets.Mania/Objects/Note.cs index 911bd2b0a2..ffc3ed0bd7 100644 --- a/osu.Game.Rulesets.Mania/Objects/Note.cs +++ b/osu.Game.Rulesets.Mania/Objects/Note.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Judgements; @@ -12,6 +11,6 @@ namespace osu.Game.Rulesets.Mania.Objects /// public class Note : ManiaHitObject { - protected override IEnumerable CreateJudgements() => new[] { new ManiaJudgement() }; + protected override Judgement CreateJudgement() => new ManiaJudgement(); } } diff --git a/osu.Game.Rulesets.Mania/Objects/TailNote.cs b/osu.Game.Rulesets.Mania/Objects/TailNote.cs index 0f00ee3938..522f78336f 100644 --- a/osu.Game.Rulesets.Mania/Objects/TailNote.cs +++ b/osu.Game.Rulesets.Mania/Objects/TailNote.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Mania.Judgements; @@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Mania.Objects { public class TailNote : Note { - protected override IEnumerable CreateJudgements() => new[] { new ManiaJudgement() }; + protected override Judgement CreateJudgement() => new ManiaJudgement(); } } diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs index e44016e48b..79866b8a4a 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs @@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Osu.Tests if (auto && !userTriggered && timeOffset > 0) { // force success - ApplyResult(Results.Single(), r => r.Type = HitResult.Great); + ApplyResult(r => r.Type = HitResult.Great); } else base.CheckForJudgements(userTriggered, timeOffset); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index a09748e450..15521113ed 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; @@ -82,7 +81,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (!userTriggered) { if (!HitObject.HitWindows.CanBeHit(timeOffset)) - ApplyResult(Results.Single(), r => r.Type = HitResult.Miss); + ApplyResult(r => r.Type = HitResult.Miss); return; } @@ -91,7 +90,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (result == HitResult.None) return; - ApplyResult(Results.Single(), r => r.Type = result); + ApplyResult(r => r.Type = result); } protected override void UpdatePreemptState() diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index 187cbc29a2..2529ac20c4 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -4,7 +4,6 @@ using System; using osu.Game.Rulesets.Objects.Drawables; using osu.Framework.Graphics; -using System.Linq; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Judgements; @@ -35,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { UpdatePreemptState(); - var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), Results.FirstOrDefault()?.TimeOffset ?? 0); + var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), Result?.TimeOffset ?? 0); using (BeginDelayedSequence(HitObject.TimePreempt + judgementOffset, true)) UpdateCurrentState(state); diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs index 7ef56f07e2..ea1ee9fb1e 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using osu.Framework.Graphics; using osu.Framework.MathUtils; using osu.Game.Rulesets.Objects.Drawables; @@ -45,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (repeatPoint.StartTime <= Time.Current) - ApplyResult(Results.Single(), r => r.Type = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss); + ApplyResult(r => r.Type = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss); } protected override void UpdatePreemptState() diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs index fc6510471b..71be07f166 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -136,16 +136,16 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (userTriggered || Time.Current < slider.EndTime) return; - ApplyResult(Results.Single(), r => + ApplyResult(r => { var judgementsCount = NestedHitObjects.Count(); var judgementsHit = NestedHitObjects.Count(h => h.IsHit); var hitFraction = (double)judgementsHit / judgementsCount; - if (hitFraction == 1 && HeadCircle.Results.Single().Type == HitResult.Great) + if (hitFraction == 1 && HeadCircle.Result.Type == HitResult.Great) r.Type = HitResult.Great; - else if (hitFraction >= 0.5 && HeadCircle.Results.Single().Type >= HitResult.Good) + else if (hitFraction >= 0.5 && HeadCircle.Result.Type >= HitResult.Good) r.Type = HitResult.Good; else if (hitFraction > 0) r.Type = HitResult.Meh; diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs index 7cbb7db6d4..9261741a12 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Scoring; @@ -32,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (!userTriggered && timeOffset >= 0) - ApplyResult(Results.Single(), r => r.Type = Tracking ? HitResult.Great : HitResult.Miss); + ApplyResult(r => r.Type = Tracking ? HitResult.Great : HitResult.Miss); } } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs index c4c853cb58..8819fa962b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Linq; using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; @@ -51,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (timeOffset >= 0) - ApplyResult(Results.Single(), r => r.Type = Tracking ? HitResult.Great : HitResult.Miss); + ApplyResult(r => r.Type = Tracking ? HitResult.Great : HitResult.Miss); } protected override void UpdatePreemptState() diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 4db928c578..3feb612c8b 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (userTriggered || Time.Current < Spinner.EndTime) return; - ApplyResult(Results.Single(), r => + ApplyResult(r => { if (Progress >= 1) r.Type = HitResult.Great; diff --git a/osu.Game.Rulesets.Osu/Objects/HitCircle.cs b/osu.Game.Rulesets.Osu/Objects/HitCircle.cs index 2514988e9f..b5e64e9e40 100644 --- a/osu.Game.Rulesets.Osu/Objects/HitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/HitCircle.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Osu.Judgements; @@ -9,6 +8,6 @@ namespace osu.Game.Rulesets.Osu.Objects { public class HitCircle : OsuHitObject { - protected override IEnumerable CreateJudgements() => new[] { new OsuJudgement() }; + protected override Judgement CreateJudgement() => new OsuJudgement(); } } diff --git a/osu.Game.Rulesets.Osu/Objects/RepeatPoint.cs b/osu.Game.Rulesets.Osu/Objects/RepeatPoint.cs index ef794eafdb..83f7f79f39 100644 --- a/osu.Game.Rulesets.Osu/Objects/RepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/RepeatPoint.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Judgements; @@ -28,6 +27,6 @@ namespace osu.Game.Rulesets.Osu.Objects TimePreempt = Math.Min(SpanDuration * 2, TimePreempt); } - protected override IEnumerable CreateJudgements() => new[] { new OsuJudgement() }; + protected override Judgement CreateJudgement() => new OsuJudgement(); } } diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 54899fb9f5..eead98ac28 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -214,6 +214,6 @@ namespace osu.Game.Rulesets.Osu.Objects } } - protected override IEnumerable CreateJudgements() => new[] { new OsuJudgement() }; + protected override Judgement CreateJudgement() => new OsuJudgement(); } } diff --git a/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs b/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs index 93c8d94920..faa325d416 100644 --- a/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Osu.Judgements; @@ -14,6 +13,6 @@ namespace osu.Game.Rulesets.Osu.Objects { } - protected override IEnumerable CreateJudgements() => new[] { new OsuSliderTailJudgement() }; + protected override Judgement CreateJudgement() => new OsuSliderTailJudgement(); } } diff --git a/osu.Game.Rulesets.Osu/Objects/SliderTick.cs b/osu.Game.Rulesets.Osu/Objects/SliderTick.cs index 24ab812649..000781dec6 100644 --- a/osu.Game.Rulesets.Osu/Objects/SliderTick.cs +++ b/osu.Game.Rulesets.Osu/Objects/SliderTick.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Judgements; @@ -30,6 +29,6 @@ namespace osu.Game.Rulesets.Osu.Objects TimePreempt = (StartTime - SpanStartTime) / 2 + offset; } - protected override IEnumerable CreateJudgements() => new[] { new OsuJudgement() }; + protected override Judgement CreateJudgement() => new OsuJudgement(); } } diff --git a/osu.Game.Rulesets.Osu/Objects/Spinner.cs b/osu.Game.Rulesets.Osu/Objects/Spinner.cs index f7bb806503..d100e33f17 100644 --- a/osu.Game.Rulesets.Osu/Objects/Spinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Spinner.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; -using System.Collections.Generic; using osu.Game.Beatmaps; using osu.Game.Rulesets.Objects.Types; using osu.Game.Beatmaps.ControlPoints; @@ -33,6 +32,6 @@ namespace osu.Game.Rulesets.Osu.Objects SpinsRequired = (int)Math.Max(1, SpinsRequired * 0.6); } - protected override IEnumerable CreateJudgements() => new[] { new OsuJudgement() }; + protected override Judgement CreateJudgement() => new OsuJudgement(); } } diff --git a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs index 06f2d689d8..2b2daec8c6 100644 --- a/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs +++ b/osu.Game/Rulesets/Objects/Drawables/DrawableHitObject.cs @@ -46,7 +46,7 @@ namespace osu.Game.Rulesets.Objects.Drawables /// /// Whether this and all of its nested s have been hit. /// - public bool IsHit => Results.All(j => j.IsHit) && NestedHitObjects.All(n => n.IsHit); + public bool IsHit => (Result?.IsHit ?? true) && NestedHitObjects.All(n => n.IsHit); /// /// Whether this and all of its nested s have been judged. @@ -57,17 +57,9 @@ namespace osu.Game.Rulesets.Objects.Drawables /// Whether this has been judged. /// Note: This does NOT include nested hitobjects. /// - public bool Judged => Results.All(h => h.HasResult); + public bool Judged => Result?.HasResult ?? true; - private readonly List results = new List(); - public IReadOnlyList Results => results; - - /// - /// The that affects whether this has been hit or missed. - /// By default, this is the last in , and should be overridden if the order - /// of s in doesn't list the main as its last element. - /// - protected virtual JudgementResult MainResult => Results.LastOrDefault(); + public readonly JudgementResult Result; private bool judgementOccurred; @@ -85,8 +77,8 @@ namespace osu.Game.Rulesets.Objects.Drawables { HitObject = hitObject; - foreach (var j in hitObject.Judgements) - results.Add(CreateJudgementResult(j)); + if (hitObject.Judgement != null) + Result = CreateJudgementResult(hitObject.Judgement); } [BackgroundDependencyLoader] @@ -144,20 +136,15 @@ namespace osu.Game.Rulesets.Objects.Drawables { base.Update(); - if (lastUpdateTime > Time.Current) + if (Result != null && lastUpdateTime > Time.Current) { var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; - for (int i = Results.Count - 1; i >= 0; i--) + if (Result.TimeOffset + endTime < Time.Current) { - var judgement = Results[i]; + OnJudgementRemoved?.Invoke(this, Result); - if (judgement.TimeOffset + endTime <= Time.Current) - break; - - OnJudgementRemoved?.Invoke(this, judgement); - - judgement.Type = HitResult.None; + Result.Type = HitResult.None; State.Value = ArmedState.Idle; } } @@ -185,36 +172,29 @@ namespace osu.Game.Rulesets.Objects.Drawables /// Notifies that a new judgement has occurred for this . /// /// The . - protected void ApplyResult(JudgementResult result, Action application) + protected void ApplyResult(Action application) { - // Todo: Unsure if we want to keep this - if (!Results.Contains(result)) - throw new ArgumentException($"The applied judgement result must be a part of {Results}."); - - application?.Invoke(result); + application?.Invoke(Result); judgementOccurred = true; // Ensure that the judgement is given a valid time offset, because this may not get set by the caller var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime; - result.TimeOffset = Time.Current - endTime; + Result.TimeOffset = Time.Current - endTime; - if (result == MainResult) + switch (Result.Type) { - switch (result.Type) - { - case HitResult.None: - break; - case HitResult.Miss: - State.Value = ArmedState.Miss; - break; - default: - State.Value = ArmedState.Hit; - break; - } + case HitResult.None: + break; + case HitResult.Miss: + State.Value = ArmedState.Miss; + break; + default: + State.Value = ArmedState.Hit; + break; } - OnJudgement?.Invoke(this, result); + OnJudgement?.Invoke(this, Result); } /// diff --git a/osu.Game/Rulesets/Objects/HitObject.cs b/osu.Game/Rulesets/Objects/HitObject.cs index 0e029a8657..531a8bed38 100644 --- a/osu.Game/Rulesets/Objects/HitObject.cs +++ b/osu.Game/Rulesets/Objects/HitObject.cs @@ -3,7 +3,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Newtonsoft.Json; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Lists; @@ -64,8 +63,7 @@ namespace osu.Game.Rulesets.Objects [JsonIgnore] public IReadOnlyList NestedHitObjects => nestedHitObjects.Value; - private readonly List judgements = new List(); - public IReadOnlyList Judgements => judgements; + public Judgement Judgement { get; private set; } /// /// Applies default values to this HitObject. @@ -76,8 +74,7 @@ namespace osu.Game.Rulesets.Objects { ApplyDefaultsToSelf(controlPointInfo, difficulty); - judgements.Clear(); - judgements.AddRange(CreateJudgements()); + Judgement = CreateJudgement(); if (nestedHitObjects.IsValueCreated) nestedHitObjects.Value.Clear(); @@ -111,7 +108,7 @@ namespace osu.Game.Rulesets.Objects { } - protected virtual IEnumerable CreateJudgements() => Enumerable.Empty(); + protected virtual Judgement CreateJudgement() => null; protected void AddNested(HitObject hitObject) => nestedHitObjects.Value.Add(hitObject); diff --git a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs index 64dcf150cf..985cfce6aa 100644 --- a/osu.Game/Rulesets/Scoring/ScoreProcessor.cs +++ b/osu.Game/Rulesets/Scoring/ScoreProcessor.cs @@ -224,13 +224,13 @@ namespace osu.Game.Rulesets.Scoring foreach (var nested in obj.NestedHitObjects) simulate(nested); - foreach (var judgement in obj.Judgements) - { - var result = CreateJudgementResult(judgement); - result.Type = judgement.MaxResult; + if (obj.Judgement == null) + return; - AddJudgement(result); - } + var result = CreateJudgementResult(obj.Judgement); + result.Type = obj.Judgement.MaxResult; + + AddJudgement(result); } }