From d3a9f2ff3b67970488e4b745dada3e010aee76eb Mon Sep 17 00:00:00 2001 From: Derrick Timmermans Date: Mon, 19 Feb 2024 16:52:57 +0100 Subject: [PATCH] Update ApplyResult usages --- .../Judgements/SentakkiJudgementResult.cs | 2 +- .../Drawables/DrawableScoreBonusObject.cs | 11 ++------ .../Drawables/DrawableScorePaddingObject.cs | 17 ++++++++++--- .../Drawables/DrawableSentakkiHitObject.cs | 25 +++++++++++-------- .../DrawableSentakkiLanedHitObject.cs | 7 +++--- .../Drawables/DrawableSlideCheckpoint.cs | 9 ++++--- .../Drawables/DrawableSlideCheckpointNode.cs | 9 ++++++- 7 files changed, 49 insertions(+), 31 deletions(-) diff --git a/osu.Game.Rulesets.Sentakki/Judgements/SentakkiJudgementResult.cs b/osu.Game.Rulesets.Sentakki/Judgements/SentakkiJudgementResult.cs index bd0e357c1..b96b37437 100644 --- a/osu.Game.Rulesets.Sentakki/Judgements/SentakkiJudgementResult.cs +++ b/osu.Game.Rulesets.Sentakki/Judgements/SentakkiJudgementResult.cs @@ -20,5 +20,5 @@ public SentakkiJudgementResult(HitObject hitObject, Judgement judgement) : base( } } - public bool Critical { get; private set; } + public bool Critical { get; set; } } diff --git a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScoreBonusObject.cs b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScoreBonusObject.cs index 39205d96f..3d4099eed 100644 --- a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScoreBonusObject.cs +++ b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScoreBonusObject.cs @@ -19,19 +19,12 @@ public DrawableScoreBonusObject(ScoreBonusObject? hitObject) public void TriggerResult() { - double timeOffset = Math.Abs(Time.Current - HitObject.StartTime); - - ApplyResult(r => + ApplyResult((r, dho) => { + double timeOffset = Math.Abs(Time.Current - HitObject.StartTime); bool isCrit = r.HitObject.HitWindows.ResultFor(timeOffset) == HitResult.Perfect; r.Type = isCrit ? r.Judgement.MaxResult : r.Judgement.MinResult; }); } - - public new void ApplyResult(Action application) - { - if (!Result.HasResult) - base.ApplyResult(application); - } } } diff --git a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScorePaddingObject.cs b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScorePaddingObject.cs index 7ec91a1aa..cd4148264 100644 --- a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScorePaddingObject.cs +++ b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableScorePaddingObject.cs @@ -1,6 +1,7 @@ using System; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Sentakki.Judgements; namespace osu.Game.Rulesets.Sentakki.Objects.Drawables @@ -19,10 +20,20 @@ public DrawableScorePaddingObject(ScorePaddingObject? hitObject) protected override JudgementResult CreateResult(Judgement judgement) => new SentakkiJudgementResult(HitObject, judgement); - public new void ApplyResult(Action application) + public new void ApplyResult(HitResult result) { - if (!Result.HasResult) - base.ApplyResult(application); + var SentakkiJudgementResult = (SentakkiJudgementResult)Result; + if (result == HitResult.Perfect) + { + SentakkiJudgementResult.Critical = true; + result = Result.Judgement.MaxResult; + } + else + { + SentakkiJudgementResult.Critical = false; + } + + base.ApplyResult(result); } } } diff --git a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiHitObject.cs b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiHitObject.cs index bcb4e4dc4..f00c2b860 100644 --- a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiHitObject.cs +++ b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiHitObject.cs @@ -57,11 +57,21 @@ protected override void OnApply() protected override JudgementResult CreateResult(Judgement judgement) => new SentakkiJudgementResult(HitObject, judgement); - protected void ApplyResult(HitResult result) + protected new void ApplyResult(HitResult result) { - void resultApplication(JudgementResult r) => ((SentakkiJudgementResult)r).Type = result; - - ApplyResult(resultApplication); + var SentakkiJudgementResult = (SentakkiJudgementResult)Result; + if (result == HitResult.Perfect) + { + SentakkiJudgementResult.Critical = true; + result = Result.Judgement.MaxResult; + } + else + { + SentakkiJudgementResult.Critical = false; + } + + + base.ApplyResult(result); } protected override void OnFree() @@ -95,12 +105,5 @@ protected override void UpdateInitialTransforms() } private bool transformResetQueued; - - protected new virtual void ApplyResult(Action application) - { - // Apply judgement to this object - if (!Result.HasResult) - base.ApplyResult(application); - } } } diff --git a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiLanedHitObject.cs b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiLanedHitObject.cs index dea2edce0..f19f93b18 100644 --- a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiLanedHitObject.cs +++ b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiLanedHitObject.cs @@ -5,6 +5,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Sentakki.Configuration; using osu.Game.Rulesets.Sentakki.UI; using osu.Game.Skinning; @@ -105,7 +106,7 @@ protected override void OnFree() breakSample.ClearSamples(); } - protected override void ApplyResult(Action application) + protected new void ApplyResult(HitResult hitResult) { // Judge the scoreBonus foreach (var bonusObject in scoreBonusObjects) @@ -113,9 +114,9 @@ protected override void ApplyResult(Action application) // Also give Break note score padding a judgement for (int i = 0; i < scorePaddingObjects.Count; ++i) - scorePaddingObjects[^(i + 1)].ApplyResult(application); + scorePaddingObjects[^(i + 1)].ApplyResult(hitResult); - base.ApplyResult(application); + base.ApplyResult(hitResult); } } } diff --git a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs index 94e72ff98..da0a1ac0f 100644 --- a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs +++ b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs @@ -5,6 +5,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Sentakki.Objects.Drawables { @@ -78,16 +79,18 @@ protected override void CheckForResult(bool userTriggered, double timeOffset) ApplyResult(Result.Judgement.MaxResult); } - protected override void ApplyResult(Action application) + + + protected new void ApplyResult(HitResult result) { if (Judged) return; // Make sure remaining nodes are judged foreach (var node in nodes) - node.ApplyResult(application); + node.ApplyResult(result); - base.ApplyResult(application); + base.ApplyResult(result); } // Forcefully miss this node, used when players fail to complete the slide on time. diff --git a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpointNode.cs b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpointNode.cs index 0d6d83fee..b9546f99a 100644 --- a/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpointNode.cs +++ b/osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpointNode.cs @@ -3,6 +3,7 @@ using osu.Framework.Graphics; using osu.Framework.Input; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Scoring; using osuTK; namespace osu.Game.Rulesets.Sentakki.Objects.Drawables @@ -82,6 +83,12 @@ private bool checkForTouchInput() return false; } - public new void ApplyResult(Action application) => base.ApplyResult(application); + public new void ApplyResult(HitResult result) + { + if (Judged) + return; + + base.ApplyResult(result); + } } }