From f16400929d7eaddaddce0e0c56c30ae5254497e9 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 20 Oct 2023 15:37:51 +0900 Subject: [PATCH] Update bindable flow to expose every spin, even after max bonus is reached --- .../Objects/Drawables/DrawableSpinner.cs | 29 +++++++++---------- .../Skinning/Argon/ArgonSpinner.cs | 8 ++--- .../Skinning/Default/DefaultSpinner.cs | 8 ++--- .../Skinning/Legacy/LegacySpinner.cs | 8 ++--- 4 files changed, 26 insertions(+), 27 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs index 9fa180cf93..72bf7bf1e9 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableSpinner.cs @@ -48,9 +48,16 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables /// /// The amount of bonus score gained from spinning after the required number of spins, for display purposes. /// - public IBindable GainedBonus => gainedBonus; + public double CurrentBonusScore => score_per_tick * (completedFullSpins.Value - HitObject.SpinsRequiredForBonus); - private readonly Bindable gainedBonus = new BindableDouble(); + /// + /// The maximum amount of bonus score which can be achieved from extra spins. + /// + public double MaximumBonusScore => score_per_tick * HitObject.MaximumBonusSpins; + + public IBindable CompletedFullSpins => completedFullSpins; + + private readonly Bindable completedFullSpins = new Bindable(); /// /// The number of spins per minute this spinner is spinning at, for display purposes. @@ -286,8 +293,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private static readonly int score_per_tick = new SpinnerBonusTick.OsuSpinnerBonusTickJudgement().MaxNumericResult; - private int completedFullSpins; - private void updateBonusScore() { if (ticks.Count == 0) @@ -295,27 +300,21 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables int spins = (int)(Result.TotalRotation / 360); - if (spins < completedFullSpins) + if (spins < completedFullSpins.Value) { // rewinding, silently handle - completedFullSpins = spins; + completedFullSpins.Value = spins; return; } - while (completedFullSpins != spins) + while (completedFullSpins.Value != spins) { var tick = ticks.FirstOrDefault(t => !t.Result.HasResult); // tick may be null if we've hit the spin limit. - if (tick != null) - { - tick.TriggerResult(true); + tick?.TriggerResult(true); - if (tick is DrawableSpinnerBonusTick) - gainedBonus.Value = score_per_tick * (spins - HitObject.SpinsRequiredForBonus); - } - - completedFullSpins++; + completedFullSpins.Value++; } } } diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs index d5a9cf46c5..dc701aef53 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSpinner.cs @@ -85,17 +85,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon }; } - private IBindable gainedBonus = null!; + private IBindable completedSpins = null!; private IBindable spinsPerMinute = null!; protected override void LoadComplete() { base.LoadComplete(); - gainedBonus = drawableSpinner.GainedBonus.GetBoundCopy(); - gainedBonus.BindValueChanged(bonus => + completedSpins = drawableSpinner.CompletedFullSpins.GetBoundCopy(); + completedSpins.BindValueChanged(bonus => { - bonusCounter.Text = bonus.NewValue.ToString(NumberFormatInfo.InvariantInfo); + bonusCounter.Text = drawableSpinner.CurrentBonusScore.ToString(NumberFormatInfo.InvariantInfo); bonusCounter.FadeOutFromOne(1500); bonusCounter.ScaleTo(1.5f).Then().ScaleTo(1f, 1000, Easing.OutQuint); }); diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs index 071fbe6add..e001aeceae 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/DefaultSpinner.cs @@ -80,17 +80,17 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default }); } - private IBindable gainedBonus = null!; + private IBindable completedSpins = null!; private IBindable spinsPerMinute = null!; protected override void LoadComplete() { base.LoadComplete(); - gainedBonus = drawableSpinner.GainedBonus.GetBoundCopy(); - gainedBonus.BindValueChanged(bonus => + completedSpins = drawableSpinner.CompletedFullSpins.GetBoundCopy(); + completedSpins.BindValueChanged(bonus => { - bonusCounter.Text = bonus.NewValue.ToString(NumberFormatInfo.InvariantInfo); + bonusCounter.Text = drawableSpinner.CurrentBonusScore.ToString(NumberFormatInfo.InvariantInfo); bonusCounter.FadeOutFromOne(1500); bonusCounter.ScaleTo(1.5f).Then().ScaleTo(1f, 1000, Easing.OutQuint); }); diff --git a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySpinner.cs b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySpinner.cs index d8f837ae5e..456f041554 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySpinner.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Legacy/LegacySpinner.cs @@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy }); } - private IBindable gainedBonus = null!; + private IBindable completedSpins = null!; private IBindable spinsPerMinute = null!; private readonly Bindable completed = new Bindable(); @@ -116,10 +116,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy { base.LoadComplete(); - gainedBonus = DrawableSpinner.GainedBonus.GetBoundCopy(); - gainedBonus.BindValueChanged(bonus => + completedSpins = DrawableSpinner.CompletedFullSpins.GetBoundCopy(); + completedSpins.BindValueChanged(bonus => { - bonusCounter.Text = bonus.NewValue.ToString(NumberFormatInfo.InvariantInfo); + bonusCounter.Text = DrawableSpinner.CurrentBonusScore.ToString(NumberFormatInfo.InvariantInfo); bonusCounter.FadeOutFromOne(800, Easing.Out); bonusCounter.ScaleTo(SPRITE_SCALE * 2f).Then().ScaleTo(SPRITE_SCALE * 1.28f, 800, Easing.Out); });