public static void LoadSimulationSave() { string backupFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/KCT_simulation_backup.sfs"; string saveFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/persistent.sfs"; KCT_Utilities.disableSimulationLocks(); KCT_GameStates.flightSimulated = false; Kerbal_Construction_Time.moved = false; KCT_GameStates.simulationEndTime = 0; KCTDebug.Log("Swapping persistent.sfs with simulation backup file."); System.IO.File.Copy(backupFile, saveFile, true); System.IO.File.Delete(backupFile); }
public void gameSceneEvent(GameScenes scene) { if (!KCT_GameStates.settings.enabledForSave) { return; } List <GameScenes> validScenes = new List <GameScenes> { GameScenes.SPACECENTER, GameScenes.TRACKSTATION, GameScenes.SPH, GameScenes.EDITOR }; if (validScenes.Contains(scene)) { //Check for simulation save and load it. if (System.IO.File.Exists(KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/KCT_simulation_backup.sfs")) { KCT_Utilities.LoadSimulationSave(); } } if (!HighLogic.LoadedSceneIsFlight && scene == GameScenes.FLIGHT && KCT_GameStates.flightSimulated) //Backup save at simulation start { KCT_Utilities.MakeSimulationSave(); } if (HighLogic.LoadedScene == scene && (scene == GameScenes.EDITOR || scene == GameScenes.SPH)) //Fix for null reference when using new or load buttons in editor { GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE); } if (scene == GameScenes.MAINMENU) { KCT_GameStates.reset(); KCT_GameStates.firstStart = true; KCT_Utilities.disableSimulationLocks(); InputLockManager.RemoveControlLock("KCTLaunchLock"); } if (HighLogic.LoadedSceneIsEditor) { EditorLogic.fetch.Unlock("KCTEditorMouseLock"); } }