From d54f3e2b88abd28523100a2dce29515b5634f39d Mon Sep 17 00:00:00 2001 From: cake Date: Thu, 1 Oct 2026 17:02:57 -0400 Subject: [PATCH] autoplayer spin patch --- scripts/game/managers/CursorManager.cs | 38 ++++++++++++++++--------- scripts/scenes/Game.cs | 2 +- scripts/shaders/combo_progress.gdshader | 2 +- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/scripts/game/managers/CursorManager.cs b/scripts/game/managers/CursorManager.cs index be41756c..2420df1c 100644 --- a/scripts/game/managers/CursorManager.cs +++ b/scripts/game/managers/CursorManager.cs @@ -125,27 +125,39 @@ public void UpdateCursor(Vector2 inputDelta, int cursorIndex = 0) public void UpdateAutoplayCursor(Vector2 position) { + if (!position.IsFinite()) + return; + EmitSignalOnCursorUpdated(position); var attempt = runner.Attempt; - attempt.RawCursorPosition = position; - attempt.CursorPosition = position.Clamp(-Constants.BOUNDS, Constants.BOUNDS); - - var origin = new Vector3(0, 0, attempt.CameraMode.Name == "Spin" ? 4f : 3.75f); - float parallax = (float)settings.CameraParallax; - camera.Position = origin + new Vector3(attempt.CursorPosition.X, attempt.CursorPosition.Y, 0) * parallax; + position = position.Clamp(-Constants.BOUNDS, Constants.BOUNDS); - if (attempt.CameraMode.Name != "Spin") + if (attempt.CameraMode is CameraSpin) { - camera.Rotation = Vector3.Zero; - } + Vector3 target = new(position.X, position.Y, 0); + Vector3 previousCursor = new(attempt.CursorPosition.X, attempt.CursorPosition.Y, 0); + var origin = new Vector3(0, 0, 3.5f) + previousCursor * (float)attempt.Settings.CameraParallax; - Vector3 cursorPos = new(attempt.CursorPosition.X, attempt.CursorPosition.Y, 0); + var targetRotation = Basis.LookingAt(target - origin, Vector3.Up); + var targetEuler = targetRotation.GetEuler(); + float pitch = targetEuler.X - camera.Rotation.X; + float yaw = Mathf.AngleDifference(camera.Rotation.Y, targetEuler.Y); - if (cursorPos.IsFinite()) - { - cursors[0].Position = cursorPos; + var mouseDelta = new Vector2(-yaw, -pitch) * (120f * Mathf.Pi); + + attempt.CameraMode.Process(attempt, replayManager, camera, cursors[0], mouseDelta, 1f); + return; } + + attempt.RawCursorPosition = position; + attempt.CursorPosition = position; + + Vector3 cursorPosition = new(position.X, position.Y, 0); + camera.Position = new Vector3(0, 0, 3.76f) + cursorPosition * (float)settings.CameraParallax; + camera.Rotation = Vector3.Zero; + + cursors[0].Position = cursorPosition; } // Reset everything to zero so it doesn't have infinite sensitivity diff --git a/scripts/scenes/Game.cs b/scripts/scenes/Game.cs index c8765e0b..4a924949 100644 --- a/scripts/scenes/Game.cs +++ b/scripts/scenes/Game.cs @@ -46,7 +46,7 @@ public override void _Ready() PlayerInputController.OnMouseMove += (relative, absolute) => { - if (!Runner.Playing || Attempt.IsReplay) + if (!Runner.Playing || Attempt.IsReplay || Attempt.Modifiers.Exists(mod => mod is AutoplayModifier)) return; if (Attempt.Settings.AbsoluteInput) diff --git a/scripts/shaders/combo_progress.gdshader b/scripts/shaders/combo_progress.gdshader index 1d019de7..69d172a2 100644 --- a/scripts/shaders/combo_progress.gdshader +++ b/scripts/shaders/combo_progress.gdshader @@ -31,7 +31,7 @@ void fragment() { float dist_to_line = distance(UV, middle + dotp * normalize(point_diff)); float line_alpha = smoothstep((thickness / 256.0) + fwidth(dist_to_line), (thickness / 256.0) - fwidth(dist_to_line), dist_to_line); - + if (abs(dotp) <= distance(point_diff, vec2(0.0, 0.0)) / 2.0 + thickness) { COLOR = mix(COLOR, vec4(background_colour.rgb, 1.0), line_alpha); }