diff --git a/osu.Game.Rulesets.Osu/Mods/InputBlockingMod.cs b/osu.Game.Rulesets.Osu/Mods/InputBlockingMod.cs index 4541d33579..40d05b9475 100644 --- a/osu.Game.Rulesets.Osu/Mods/InputBlockingMod.cs +++ b/osu.Game.Rulesets.Osu/Mods/InputBlockingMod.cs @@ -62,7 +62,9 @@ public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset gameplayClock = drawableRuleset.FrameStableClock; } - protected virtual bool CheckCorrectAction(OsuAction action) + protected abstract bool CheckValidNewAction(OsuAction action); + + private bool checkCorrectAction(OsuAction action) { if (nonGameplayPeriods.IsInAny(gameplayClock.CurrentTime)) { @@ -81,6 +83,13 @@ protected virtual bool CheckCorrectAction(OsuAction action) return true; } + if (CheckValidNewAction(action)) + { + LastActionPressed = action; + return true; + } + + ruleset.Cursor.FlashColour(Colour4.Red, flash_duration, Easing.OutQuint); return false; } @@ -95,7 +104,7 @@ public InputInterceptor(InputBlockingMod mod) public bool OnPressed(KeyBindingPressEvent e) // if the pressed action is incorrect, block it from reaching gameplay. - => !mod.CheckCorrectAction(e.Action); + => !mod.checkCorrectAction(e.Action); public void OnReleased(KeyBindingReleaseEvent e) { diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModAlternate.cs b/osu.Game.Rulesets.Osu/Mods/OsuModAlternate.cs index e1be8288e3..9bc401de67 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModAlternate.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModAlternate.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; namespace osu.Game.Rulesets.Osu.Mods @@ -16,20 +15,6 @@ public class OsuModAlternate : InputBlockingMod public override IconUsage? Icon => FontAwesome.Solid.Keyboard; public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModSingleTap) }).ToArray(); - protected override bool CheckCorrectAction(OsuAction action) - { - if (base.CheckCorrectAction(action)) - return true; - - if (LastActionPressed != action) - { - // User alternated correctly. - LastActionPressed = action; - return true; - } - - Ruleset.Cursor.FlashColour(Colour4.Red, FLASH_DURATION, Easing.OutQuint); - return false; - } + protected override bool CheckValidNewAction(OsuAction action) => LastActionPressed != action; } } diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModSingleTap.cs b/osu.Game.Rulesets.Osu/Mods/OsuModSingleTap.cs index 2000adc7d9..95b798c39e 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModSingleTap.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModSingleTap.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using osu.Framework.Graphics; namespace osu.Game.Rulesets.Osu.Mods { @@ -14,26 +13,6 @@ public class OsuModSingleTap : InputBlockingMod public override string Description => @"You must only use one key!"; public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAlternate) }).ToArray(); - protected override bool CheckCorrectAction(OsuAction action) - { - if (base.CheckCorrectAction(action)) - return true; - - if (LastActionPressed == null) - { - // First keypress, store the expected action. - LastActionPressed = action; - return true; - } - - if (LastActionPressed == action) - { - // User singletapped correctly. - return true; - } - - Ruleset.Cursor.FlashColour(Colour4.Red, FLASH_DURATION, Easing.OutQuint); - return false; - } + protected override bool CheckValidNewAction(OsuAction action) => LastActionPressed == null || LastActionPressed == action; } }