private static void ResetFromScreenshots(GameStateRestoreInfo restoreInfo) { if (!restoreInfo.isScreenshotMode) { Debug.Log(" === TimeLapser toggling screenshot mode"); DebugHandler.ToggleScreenshotMode(); } Debug.Log(String.Format(" === TimeLapser state restore: TimeScale: {0} CamPos: ({1}, {2}) OrthSize: {3}", restoreInfo.timeScale, restoreInfo.position.x, restoreInfo.position.y, restoreInfo.orthoSize)); Time.timeScale = restoreInfo.timeScale; CameraController instance = CameraController.Instance; instance.SetTargetPos(restoreInfo.position, restoreInfo.orthoSize, playSound: false); instance.SnapTo(restoreInfo.position); InputBlockerPatch.blockInput = false; }
private static void Postfix(SaveLoader __instance, string filename, bool isAutoSave, bool updateSavePointer) { var currentTime = System.DateTime.UtcNow; if (!isAutoSave || lastPostfixTime + TimeSpan.FromSeconds(1) > currentTime) { return; } lastPostfixTime = currentTime; Debug.Log(" === TimeLapser_SaveLoader_Save Postfix === "); var lastState = new GameStateRestoreInfo(); var presetLocation = GetSavedCameraLocation(savedViewIndex); SetupForScreenshots(presetLocation); SafeDelayedAction.EnqueueAction(() => { try { Debug.Log(" === TimeLapser Taking screenshot"); Utilities.PressScreenShotKey(); } catch (Exception e) { Debug.LogError(" === TimeLapser Error encountered during state restore"); Debug.LogException(e); } }, 800); SafeDelayedAction.EnqueueAction(() => { try { Debug.Log(" === TimeLapser Restoring State"); ResetFromScreenshots(lastState); } catch (Exception e) { Debug.LogError(" === TimeLapser Error encountered during state restore"); Debug.LogException(e); } }, 1000); }