From 462f1033c0e10cabd675d047522f804212f7f356 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 1 Aug 2018 21:46:22 +0900 Subject: [PATCH] Migrate Rulesets.Osu to the new judgement system --- .../TestCaseHitCircle.cs | 8 +------ .../Objects/Drawables/DrawableHitCircle.cs | 9 +++----- .../Objects/Drawables/DrawableOsuHitObject.cs | 2 +- .../Objects/Drawables/DrawableRepeatPoint.cs | 3 +-- .../Objects/Drawables/DrawableSlider.cs | 21 +++++++++++-------- .../Objects/Drawables/DrawableSliderTail.cs | 5 ++--- .../Objects/Drawables/DrawableSliderTick.cs | 3 +-- .../Objects/Drawables/DrawableSpinner.cs | 16 +++++++------- osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs | 9 ++++++++ osu.Game.Rulesets.Osu/Objects/Slider.cs | 4 ++-- .../Objects/SliderTailCircle.cs | 17 +++++++++++++++ 11 files changed, 58 insertions(+), 39 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs index 7af7140fd8..eea5aa9a52 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseHitCircle.cs @@ -5,12 +5,10 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Tests.Visual; using OpenTK; -using osu.Game.Rulesets.Osu.Judgements; using System.Collections.Generic; using System; using osu.Game.Rulesets.Mods; @@ -101,11 +99,7 @@ namespace osu.Game.Rulesets.Osu.Tests if (auto && !userTriggered && timeOffset > 0) { // force success - AddJudgement(new OsuJudgement - { - Result = HitResult.Great - }); - State.Value = ArmedState.Hit; + ApplyJudgement(HitObject.Judgement, j => j.Result = 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 c525b4bd97..7fd4d11455 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -6,7 +6,6 @@ using osu.Framework.Graphics; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces; using OpenTK; -using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Scoring; using OpenTK.Graphics; @@ -82,7 +81,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (!userTriggered) { if (!HitObject.HitWindows.CanBeHit(timeOffset)) - AddJudgement(new OsuJudgement { Result = HitResult.Miss }); + ApplyJudgement(HitObject.Judgement, j => j.Result = HitResult.Miss); + return; } @@ -90,10 +90,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables if (result == HitResult.None) return; - AddJudgement(new OsuJudgement - { - Result = result, - }); + ApplyJudgement(HitObject.Judgement, j => j.Result = 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 5dc141bed0..6e24f1bc83 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables { UpdatePreemptState(); - var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), Judgements.FirstOrDefault()?.TimeOffset ?? 0); + var judgementOffset = Math.Min(HitObject.HitWindows.HalfWindowFor(HitResult.Miss), HitObject.Judgements.FirstOrDefault()?.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 6bff1380d6..809b27e065 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableRepeatPoint.cs @@ -8,7 +8,6 @@ using osu.Framework.MathUtils; using osu.Game.Rulesets.Objects.Drawables; using OpenTK; using osu.Game.Graphics; -using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; @@ -45,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (repeatPoint.StartTime <= Time.Current) - AddJudgement(new OsuJudgement { Result = drawableSlider.Tracking ? HitResult.Great : HitResult.Miss }); + ApplyJudgement(HitObject.Judgement, j => j.Result = 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 f1907a92a8..6739c3a822 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSlider.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Graphics.Containers; -using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Configuration; using osu.Game.Rulesets.Scoring; using OpenTK.Graphics; @@ -134,21 +133,25 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { - if (!userTriggered && Time.Current >= slider.EndTime) + if (userTriggered || Time.Current < slider.EndTime) + return; + + ApplyJudgement(HitObject.Judgement, j => { var judgementsCount = NestedHitObjects.Count(); var judgementsHit = NestedHitObjects.Count(h => h.IsHit); var hitFraction = (double)judgementsHit / judgementsCount; - if (hitFraction == 1 && HeadCircle.Judgements.Any(j => j.Result == HitResult.Great)) - AddJudgement(new OsuJudgement { Result = HitResult.Great }); - else if (hitFraction >= 0.5 && HeadCircle.Judgements.Any(j => j.Result >= HitResult.Good)) - AddJudgement(new OsuJudgement { Result = HitResult.Good }); + + if (hitFraction == 1 && HeadCircle.HitObject.Judgement.Result == HitResult.Great) + j.Result = HitResult.Great; + else if (hitFraction >= 0.5 && HeadCircle.HitObject.Judgement.Result >= HitResult.Good) + j.Result = HitResult.Good; else if (hitFraction > 0) - AddJudgement(new OsuJudgement { Result = HitResult.Meh }); + j.Result = HitResult.Meh; else - AddJudgement(new OsuJudgement { Result = HitResult.Miss }); - } + j.Result = HitResult.Miss; + }); } protected override void UpdateCurrentState(ArmedState state) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs index fee663963e..64c4a8ef18 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTail.cs @@ -2,7 +2,6 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; -using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Osu.Objects.Drawables @@ -16,7 +15,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public bool Tracking { get; set; } - public DrawableSliderTail(Slider slider, HitCircle hitCircle) + public DrawableSliderTail(Slider slider, SliderTailCircle hitCircle) : base(hitCircle) { Origin = Anchor.Centre; @@ -32,7 +31,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (!userTriggered && timeOffset >= 0) - AddJudgement(new OsuSliderTailJudgement { Result = Tracking ? HitResult.Great : HitResult.Miss }); + ApplyJudgement(HitObject.Judgement, j => j.Result = 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 a5ecb63d12..f7b403a5cc 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderTick.cs @@ -6,7 +6,6 @@ using osu.Game.Rulesets.Objects.Drawables; using OpenTK; using OpenTK.Graphics; using osu.Framework.Graphics.Shapes; -using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Scoring; using osu.Game.Skinning; using osu.Framework.Graphics.Containers; @@ -51,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables protected override void CheckForJudgements(bool userTriggered, double timeOffset) { if (timeOffset >= 0) - AddJudgement(new OsuJudgement { Result = Tracking ? HitResult.Great : HitResult.Miss }); + ApplyJudgement(HitObject.Judgement, j => j.Result = 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 1d3df69fb8..4a0303f00f 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -11,7 +11,6 @@ using OpenTK.Graphics; using osu.Game.Graphics; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Allocation; -using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Screens.Ranking; using osu.Game.Rulesets.Scoring; @@ -136,17 +135,20 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables glow.FadeColour(completeColour, duration); } - if (!userTriggered && Time.Current >= Spinner.EndTime) + if (userTriggered || Time.Current < Spinner.EndTime) + return; + + ApplyJudgement(HitObject.Judgement, j => { if (Progress >= 1) - AddJudgement(new OsuJudgement { Result = HitResult.Great }); + j.Result = HitResult.Great; else if (Progress > .9) - AddJudgement(new OsuJudgement { Result = HitResult.Good }); + j.Result = HitResult.Good; else if (Progress > .75) - AddJudgement(new OsuJudgement { Result = HitResult.Meh }); + j.Result = HitResult.Meh; else if (Time.Current >= Spinner.EndTime) - AddJudgement(new OsuJudgement { Result = HitResult.Miss }); - } + j.Result = HitResult.Miss; + }); } [BackgroundDependencyLoader] diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs index 48a6365c00..3927ed02d5 100644 --- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs @@ -2,12 +2,15 @@ // 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; using OpenTK; using osu.Game.Rulesets.Objects.Types; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Edit.Types; +using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Osu.Judgements; namespace osu.Game.Rulesets.Osu.Objects { @@ -73,5 +76,11 @@ namespace osu.Game.Rulesets.Osu.Objects public virtual void OffsetPosition(Vector2 offset) => Position += offset; protected override HitWindows CreateHitWindows() => new OsuHitWindows(); + + public OsuJudgement Judgement { get; private set; } + + protected override IEnumerable CreateJudgements() => new[] { Judgement = CreateJudgement() }; + + protected virtual OsuJudgement CreateJudgement() => new OsuJudgement(); } } diff --git a/osu.Game.Rulesets.Osu/Objects/Slider.cs b/osu.Game.Rulesets.Osu/Objects/Slider.cs index 698f9de787..972dd42fd6 100644 --- a/osu.Game.Rulesets.Osu/Objects/Slider.cs +++ b/osu.Game.Rulesets.Osu/Objects/Slider.cs @@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Osu.Objects public double TickDistance; public HitCircle HeadCircle; - public HitCircle TailCircle; + public SliderTailCircle TailCircle; protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { @@ -133,7 +133,7 @@ namespace osu.Game.Rulesets.Osu.Objects ComboIndex = ComboIndex, }; - TailCircle = new SliderCircle(this) + TailCircle = new SliderTailCircle(this) { StartTime = EndTime, Position = EndPosition, diff --git a/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs b/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs new file mode 100644 index 0000000000..3fae9e9f8a --- /dev/null +++ b/osu.Game.Rulesets.Osu/Objects/SliderTailCircle.cs @@ -0,0 +1,17 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Rulesets.Osu.Judgements; + +namespace osu.Game.Rulesets.Osu.Objects +{ + public class SliderTailCircle : SliderCircle + { + public SliderTailCircle(Slider slider) + : base(slider) + { + } + + protected override OsuJudgement CreateJudgement() => new OsuSliderTailJudgement(); + } +}