From 3e94d4bb5ad417c2df44cff2a9818ce0b0ebdf8f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 30 May 2023 15:18:22 +0900 Subject: [PATCH] Fix cursor ripples appearing in a weird place when "autopilot" mod is enabled --- osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs index 4782a0e49c..3841c9c716 100644 --- a/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs +++ b/osu.Game.Rulesets.Osu/Mods/OsuModAutopilot.cs @@ -24,7 +24,17 @@ namespace osu.Game.Rulesets.Osu.Mods public override ModType Type => ModType.Automation; public override LocalisableString Description => @"Automatic cursor movement - just follow the rhythm."; public override double ScoreMultiplier => 0.1; - public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModFailCondition), typeof(ModNoFail), typeof(ModAutoplay), typeof(OsuModMagnetised), typeof(OsuModRepel) }; + + public override Type[] IncompatibleMods => new[] + { + typeof(OsuModSpunOut), + typeof(ModRelax), + typeof(ModFailCondition), + typeof(ModNoFail), + typeof(ModAutoplay), + typeof(OsuModMagnetised), + typeof(OsuModRepel) + }; public bool PerformFail() => false; @@ -34,7 +44,7 @@ namespace osu.Game.Rulesets.Osu.Mods private List replayFrames = null!; - private int currentFrame; + private int currentFrame = -1; public void Update(Playfield playfield) { @@ -43,8 +53,9 @@ namespace osu.Game.Rulesets.Osu.Mods double time = playfield.Clock.CurrentTime; // Very naive implementation of autopilot based on proximity to replay frames. + // Special case for the first frame is required to ensure the mouse is in a sane position until the actual time of the first frame is hit. // TODO: this needs to be based on user interactions to better match stable (pausing until judgement is registered). - if (Math.Abs(replayFrames[currentFrame + 1].Time - time) <= Math.Abs(replayFrames[currentFrame].Time - time)) + if (currentFrame < 0 || Math.Abs(replayFrames[currentFrame + 1].Time - time) <= Math.Abs(replayFrames[currentFrame].Time - time)) { currentFrame++; new MousePositionAbsoluteInput { Position = playfield.ToScreenSpace(replayFrames[currentFrame].Position) }.Apply(inputManager.CurrentState, inputManager);