Sanitise interceptor logic to now require two separate check paths

This commit is contained in:
Dean Herbert 2022-02-02 14:02:48 +09:00
parent 0036d0e26d
commit fed63abd83
1 changed files with 13 additions and 8 deletions

View File

@ -33,8 +33,6 @@ public class OsuModAlternate : Mod, IApplicableToDrawableRuleset<OsuHitObject>,
private OsuAction? lastActionPressed;
private DrawableRuleset<OsuHitObject> ruleset;
private bool shouldAlternate => !isBreakTime.Value && introEnded;
public void ApplyToDrawableRuleset(DrawableRuleset<OsuHitObject> drawableRuleset)
{
ruleset = drawableRuleset;
@ -54,16 +52,22 @@ public void ApplyToPlayer(Player player)
};
}
private bool onPressed(OsuAction key)
private bool checkCorrectAction(OsuAction action)
{
if (lastActionPressed == key)
if (isBreakTime.Value)
return true;
if (!introEnded)
return true;
if (lastActionPressed != action)
{
ruleset.Cursor.FlashColour(Colour4.Red, flash_duration, Easing.OutQuint);
// User alternated correctly
lastActionPressed = action;
return true;
}
lastActionPressed = key;
ruleset.Cursor.FlashColour(Colour4.Red, flash_duration, Easing.OutQuint);
return false;
}
@ -83,7 +87,8 @@ public InputInterceptor(OsuModAlternate mod)
}
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
=> mod.shouldAlternate && mod.onPressed(e.Action);
// if the pressed action is incorrect, block it from reaching gameplay.
=> !mod.checkCorrectAction(e.Action);
public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
{