コード例 #1
0
 private void StopSimulationAndRevert()
 {
     sim.SetSimulation(false);
     if (_status != SimVesselStatus.Launched)
     {
         return;
     }
     if (FlightDriver.PreLaunchState == null)
     {
         var configNode = GamePersistence.LoadSFSFile("simulation", HighLogic.SaveFolder);
         if (configNode != null && HighLogic.CurrentGame != null)
         {
             var game = GamePersistence.LoadGameCfg(configNode, "simulation", true, false);
             FlightDriver.StartAndFocusVessel(game, game.flightState.activeVesselIdx);
             _status = SimVesselStatus.Waiting;
             Debug.Log($"[QuickIronMan]({name}) Revert to save");
             return;
         }
         _status = SimVesselStatus.Launched;
         Debug.Log($"[QuickIronMan]({name}) Something seems wrong, no simulation save, can't return before simulation start");
         return;
     }
     FlightDriver.RevertToLaunch();
     Debug.Log($"[QuickIronMan]({name}) Revert to launch");
 }
コード例 #2
0
        public static void Load(
            string saveDir, string file = "persistent",
            GameScenes startScene       = GameScenes.SPACECENTER, MonoBehaviourExtended logger = null)
        {
            _logger = logger;
            var node = GamePersistence.LoadSFSFile(file, saveDir);

            if (node == null)
            {
                LogDebug("Couldn't load sfs {0}, {1}", "default", "persistent");
                return;
            }

            // total HACK because I don't have python's functools.partial
            _startScene = startScene;
            KSPUpgradePipeline.Process(
                node, "persistent", SaveUpgradePipeline.LoadContext.SFS, OnLoadPipe, OnLoadPipeFail);
        }
コード例 #3
0
        static void LoadGame()
        {
            if (Loaded)
            {
                return;
            }
            Loaded = true;

            Console.WriteLine("[kRPC testing tools]: Loading game \"" + Game + "\"");
            var gameObj = GamePersistence.LoadSFSFile(Save, Game);

            if (gameObj == null)
            {
                Console.WriteLine("[kRPC testing tools]: Failed to load game, got null when loading sfs file");
                return;
            }
            KSPUpgradePipeline.Process(gameObj, Game, LoadContext.SFS, OnLoadDialogPipelineFinished, OnLoadDialogPipelineError);
        }
コード例 #4
0
        public static bool LoadGame(string filename)
        {
            ConfigNode configNode = GamePersistence.LoadSFSFile(filename, HighLogic.SaveFolder);

            if (configNode == null)
            {
                ScreenMessages.PostScreenMessage("<color=orange>Unable to load the save: " + filename, 5f, ScreenMessageStyle.UPPER_LEFT);
                return(false);
            }
            var v = NodeUtil.GetCfgVersion(configNode, LoadContext.SFS);

            KSPUpgradePipeline.Process(configNode, HighLogic.SaveFolder, LoadContext.SFS,
                                       node => onPipelineFinished(node, filename, v),
                                       (opt, node) =>
                                       ScreenMessages.PostScreenMessage(string.Format("<color=orange>Unable to load the save: {0}\n" +
                                                                                      "KSPUpgradePipeline finished with error.", filename),
                                                                        5f, ScreenMessageStyle.UPPER_LEFT));
            return(true);
        }
コード例 #5
0
ファイル: AutoLoadGame.cs プロジェクト: mlheur/AutoLoadGame
        private void LoadGame()
        {
            //load the game only the first time (i.e. at game start)
            if (loaded)
            {
                return;
            }
            loaded = true;
            //get the game and the save
            if (File.Exists(config))
            {
                var cfg = ConfigNode.Load(config);
                if (cfg != null)
                {
                    var val = cfg.GetValue("game");
                    if (val != null)
                    {
                        game = val;
                    }
                    val = cfg.GetValue("save");
                    if (val != null)
                    {
                        save = val;
                    }
                }
                else
                {
                    Log("Configuration file is empty: {0}", config);
                    return;
                }
            }
            else
            {
                Log("Configuration file not found: {0}", config);
                return;
            }
            var gameDir = Path.Combine(savesDir, game);

            if (!Directory.Exists(gameDir))
            {
                Log("No game directory: {0}", gameDir);
                return;
            }
            var saveFile = Path.Combine(gameDir, save + ".sfs");

            if (!File.Exists(saveFile))
            {
                Log("No such file: {0}", saveFile);
                return;
            }
            //load the game
            var game_node = GamePersistence.LoadSFSFile(save, game);

            if (game_node == null)
            {
                Log("Unable to load the save: {0}", saveFile);
                return;
            }
            Log("Loading: {0}/{1}", game, save);
            KSPUpgradePipeline.Process(game_node,
                                       game,
                                       LoadContext.SFS,
                                       OnLoadDialogPipelineFinished,
                                       (opt, n) => Log("KSPUpgradePipeline finished with error: {0}", saveFile));
        }