mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 10:22:56 +08:00
privatise checkCorrectAction, add abstract CheckValidNewAction function
This commit is contained in:
parent
be3187c3a4
commit
0da1bd393c
@ -62,7 +62,9 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
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 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
return true;
|
||||
}
|
||||
|
||||
if (CheckValidNewAction(action))
|
||||
{
|
||||
LastActionPressed = action;
|
||||
return true;
|
||||
}
|
||||
|
||||
ruleset.Cursor.FlashColour(Colour4.Red, flash_duration, Easing.OutQuint);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -95,7 +104,7 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
|
||||
// if the pressed action is incorrect, block it from reaching gameplay.
|
||||
=> !mod.CheckCorrectAction(e.Action);
|
||||
=> !mod.checkCorrectAction(e.Action);
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)
|
||||
{
|
||||
|
@ -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 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Osu.Mods
|
||||
{
|
||||
@ -14,26 +13,6 @@ namespace osu.Game.Rulesets.Osu.Mods
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user