Merge pull request #23696 from peppy/fix-autopilot-ripples

Fix cursor ripples appearing in a weird place when "autopilot" mod is enabled
This commit is contained in:
Bartłomiej Dach 2023-05-30 23:29:30 +02:00 committed by GitHub
commit aaf50c47a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 3 deletions

View File

@ -24,7 +24,17 @@ public class OsuModAutopilot : Mod, IApplicableFailOverride, IUpdatableByPlayfie
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 @@ public class OsuModAutopilot : Mod, IApplicableFailOverride, IUpdatableByPlayfie
private List<OsuReplayFrame> replayFrames = null!;
private int currentFrame;
private int currentFrame = -1;
public void Update(Playfield playfield)
{
@ -43,8 +53,9 @@ public void Update(Playfield playfield)
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);