private void MakeControllerWork(MapEditor.orig_Update orig, Editor.MapEditor self) { orig(self); if (!SpeedrunToolModule.Enabled || !EnableQoL) { return; } zoomWaitFrames--; // pressed confirm button teleport to the select room if (Input.MenuConfirm.Pressed) { Input.MenuConfirm.ConsumePress(); Vector2 mousePosition = (Vector2)self.GetField("mousePosition"); LevelTemplate level = self.InvokeMethod("TestCheck", mousePosition) as LevelTemplate; if (level != null) { if (level.Type == LevelTemplateType.Filler) { return; } self.InvokeMethod("LoadLevel", level, mousePosition * 8f); } } // right stick zoom the map GamePadState currentState = MInput.GamePads[Input.Gamepad].CurrentState; Camera camera = typeof(Editor.MapEditor).GetField("Camera", BindingFlags.Static | BindingFlags.NonPublic) ?.GetValue(null) as Camera; if (zoomWaitFrames < 0 && camera != null) { float newZoom = 0f; if (Math.Abs(currentState.ThumbSticks.Right.X) >= 0.5f) { newZoom = camera.Zoom + Math.Sign(currentState.ThumbSticks.Right.X) * 1f; } else if (Math.Abs(currentState.ThumbSticks.Right.Y) >= 0.5f) { newZoom = camera.Zoom + Math.Sign(currentState.ThumbSticks.Right.Y) * 1f; } if (newZoom >= 1f) { camera.Zoom = newZoom; zoomWaitFrames = 5; } } // move faster when zoom out if (camera != null && camera.Zoom < 6f) { camera.Position += new Vector2(Input.MoveX.Value, Input.MoveY.Value) * 300f * Engine.DeltaTime * ((float)Math.Pow(1.3, 6 - camera.Zoom) - 1); } }
private void MapEditorOnLoadLevel(MapEditor.orig_LoadLevel orig, Editor.MapEditor self, LevelTemplate level, Vector2 at) { if (!SpeedrunToolModule.Enabled) { orig(self, level, at); return; } FixTeleportProblems = true; orig(self, level, at); FixTeleportProblems = false; }