From ed2b1a07540fe4038b03424abe14582de495b661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Wed, 23 Aug 2023 13:12:18 +0200 Subject: [PATCH] Contain entirety of legacy notelock badness inside the hit policy --- osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs | 2 +- osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs | 4 ++-- .../Objects/Drawables/DrawableHitCircle.cs | 9 +++------ .../Objects/Drawables/DrawableOsuHitObject.cs | 3 ++- .../Objects/Drawables/DrawableSliderHead.cs | 2 +- osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs | 3 ++- osu.Game.Rulesets.Osu/UI/IHitPolicy.cs | 4 +++- osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs | 6 +++++- osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs | 5 +++-- 9 files changed, 22 insertions(+), 16 deletions(-) diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs index c818a361df..af02087d1a 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircle.cs @@ -131,7 +131,7 @@ namespace osu.Game.Rulesets.Osu.Tests protected override void CheckForResult(bool userTriggered, double timeOffset) { - if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current) == ClickAction.Hit) + if (auto && !userTriggered && timeOffset > hitOffset && CheckHittable?.Invoke(this, Time.Current, HitResult.Great) == ClickAction.Hit) { // force success ApplyResult(r => r.Type = HitResult.Great); diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs index 6366a185f2..3accf4fad7 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneLegacyHitPolicy.cs @@ -635,9 +635,9 @@ namespace osu.Game.Rulesets.Osu.Tests { public List ClickActions { get; } = new List(); - public override ClickAction CheckHittable(DrawableHitObject hitObject, double time) + public override ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) { - var action = base.CheckHittable(hitObject, time); + var action = base.CheckHittable(hitObject, time, result); ClickActions.Add(action); return action; } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index 09d818def8..932f6d3fff 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -155,15 +155,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables } var result = ResultFor(timeOffset); - var clickAction = CheckHittable?.Invoke(this, Time.Current); + var clickAction = CheckHittable?.Invoke(this, Time.Current, result); - if (clickAction == ClickAction.Shake || (result == HitResult.None && clickAction != ClickAction.Ignore)) - { + if (clickAction == ClickAction.Shake) Shake(); - return; - } - if (result == HitResult.None) + if (result == HitResult.None || clickAction != ClickAction.Hit) return; ApplyResult(r => diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs index a8ce2118c8..920dfcab03 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableOsuHitObject.cs @@ -13,6 +13,7 @@ using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Osu.UI; +using osu.Game.Rulesets.Scoring; using osuTK; using osuTK.Graphics; @@ -37,7 +38,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables /// and , and this hit object will be shaken for return values of /// . /// - public Func CheckHittable; + public Func CheckHittable; protected DrawableOsuHitObject(OsuHitObject hitObject) : base(hitObject) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs index a4cf69ee31..41f6a40c0a 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSliderHead.cs @@ -61,7 +61,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables pathVersion.BindTo(DrawableSlider.PathVersion); - CheckHittable = (d, t) => DrawableSlider.CheckHittable?.Invoke(d, t) ?? ClickAction.Hit; + CheckHittable = (d, t, r) => DrawableSlider.CheckHittable?.Invoke(d, t, r) ?? ClickAction.Hit; } protected override void Update() diff --git a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs index 7503c43e0b..69bd360b5e 100644 --- a/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/AnyOrderHitPolicy.cs @@ -4,6 +4,7 @@ #nullable disable using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -15,7 +16,7 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } - public ClickAction CheckHittable(DrawableHitObject hitObject, double time) => ClickAction.Hit; + public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) => ClickAction.Hit; public void HandleHit(DrawableHitObject hitObject) { diff --git a/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs index 9820b8c188..44d3b37408 100644 --- a/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/IHitPolicy.cs @@ -3,6 +3,7 @@ using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -19,8 +20,9 @@ namespace osu.Game.Rulesets.Osu.UI /// /// The to check. /// The time to check. + /// The result that the object would be judged with if hit. /// Whether can be hit at the given . - ClickAction CheckHittable(DrawableHitObject hitObject, double time); + ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result); /// /// Handles a being hit. diff --git a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs index 6a740a6839..5260215345 100644 --- a/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/LegacyHitPolicy.cs @@ -8,6 +8,7 @@ using System.Linq; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -26,7 +27,7 @@ namespace osu.Game.Rulesets.Osu.UI { } - public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time) + public virtual ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult result) { var aliveObjects = HitObjectContainer.AliveObjects.ToList(); int index = aliveObjects.IndexOf(hitObject); @@ -38,6 +39,9 @@ namespace osu.Game.Rulesets.Osu.UI return ClickAction.Ignore; } + if (result == HitResult.None) + return ClickAction.Shake; + foreach (DrawableHitObject testObject in aliveObjects) { if (testObject.AllJudged) diff --git a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs index f33ca58aef..6fd0b512be 100644 --- a/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs +++ b/osu.Game.Rulesets.Osu/UI/StartTimeOrderedHitPolicy.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; namespace osu.Game.Rulesets.Osu.UI @@ -24,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.UI { public IHitObjectContainer HitObjectContainer { get; set; } - public ClickAction CheckHittable(DrawableHitObject hitObject, double time) + public ClickAction CheckHittable(DrawableHitObject hitObject, double time, HitResult _) { DrawableHitObject blockingObject = null; @@ -51,7 +52,7 @@ namespace osu.Game.Rulesets.Osu.UI if (!hitObjectCanBlockFutureHits(hitObject)) return; - if (CheckHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset) != ClickAction.Hit) + if (CheckHittable(hitObject, hitObject.HitObject.StartTime + hitObject.Result.TimeOffset, hitObject.Result.Type) != ClickAction.Hit) throw new InvalidOperationException($"A {hitObject} was hit before it became hittable!"); // Miss all hitobjects prior to the hit one.