diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs index f874bc271f..6286c80d7c 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModRelax.cs @@ -9,6 +9,7 @@ using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Objects.Types; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osu.Game.Rulesets.Replays; using osu.Game.Rulesets.UI; using static osu.Game.Input.Handlers.ReplayInputHandler; @@ -24,11 +25,14 @@ namespace osu.Game.Rulesets.Osu.Mods /// private const float relax_leniency = 3; - private bool wasHit; + private bool isDownState; private bool wasLeft; private OsuInputManager osuInputManager; + private ReplayState state; + private double lastStateChangeTime; + public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) { // grab the input manager for future use. @@ -75,11 +79,14 @@ namespace osu.Game.Rulesets.Osu.Mods if (requiresHit) { - addAction(false); - addAction(true); + changeState(false); + changeState(true); } - addAction(requiresHold); + if (requiresHold) + changeState(true); + else if (isDownState && time - lastStateChangeTime > AutoGenerator.KEY_UP_DELAY) + changeState(false); void handleHitCircle(DrawableHitCircle circle) { @@ -89,27 +96,28 @@ namespace osu.Game.Rulesets.Osu.Mods Debug.Assert(circle.HitObject.HitWindows != null); requiresHit |= circle.HitObject.HitWindows.CanBeHit(time - circle.HitObject.StartTime); } - } - private void addAction(bool hitting) - { - if (wasHit == hitting) - return; - - wasHit = hitting; - - var state = new ReplayState + void changeState(bool down) { - PressedActions = new List() - }; + if (isDownState == down) + return; - if (hitting) - { - state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton); - wasLeft = !wasLeft; + isDownState = down; + lastStateChangeTime = time; + + state = new ReplayState + { + PressedActions = new List() + }; + + if (down) + { + state.PressedActions.Add(wasLeft ? OsuAction.LeftButton : OsuAction.RightButton); + wasLeft = !wasLeft; + } + + state?.Apply(osuInputManager.CurrentState, osuInputManager); } - - state.Apply(osuInputManager.CurrentState, osuInputManager); } } } diff --git a/osu.Game/Rulesets/Replays/AutoGenerator.cs b/osu.Game/Rulesets/Replays/AutoGenerator.cs index 3319f30a6f..b3c609f2f4 100644 --- a/osu.Game/Rulesets/Replays/AutoGenerator.cs +++ b/osu.Game/Rulesets/Replays/AutoGenerator.cs @@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Replays #region Constants // Shared amongst all modes - protected const double KEY_UP_DELAY = 50; + public const double KEY_UP_DELAY = 50; #endregion