Пример #1
0
 void ShowSaveGameDialog(int id)
 {
     GUILayout.BeginHorizontal();
     GUILayout.Label(Localizer.Format("#autoLOC_417232"), smallText);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     saveName = GUILayout.TextField(saveName, smallInputText);
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (saveName == "")
     {
         GUI.enabled = false;
     }
     if (GUILayout.Button(Localizer.Format("#autoLOC_455877")))
     {
         GamePersistence.SaveGame(saveName, HighLogic.SaveFolder, SaveMode.OVERWRITE);
         showSaveGame = false;
         gamePause    = false;
         FlightDriver.SetPause(false);
     }
     GUI.enabled = true;
     GUILayout.EndHorizontal();
     GUILayout.BeginHorizontal();
     if (GUILayout.Button(Localizer.Format("autoLOC_455882")))
     {
         showSaveGame = false;
     }
     GUILayout.EndHorizontal();
     GUI.DragWindow();
 }
Пример #2
0
        public void CompleteReview()
        {
            Instance Inst = StateFundingGlobal.fetch.GameInstance;

            Review Rev = Inst.ActiveReview;

            Rev.touch();

            // Closed for business
            Rev.pastReview = true;

            // Move review to past review
            Inst.addReview(Rev);

            // Start a new review
            Inst.ActiveReview = new Review();

            // Apply PO/SC decay on instance
            ApplyDecay();

            // Apply funds from Review
            Debug.Log("Adding Funds: " + Rev.funds);
            Funding.Instance.AddFunds(Rev.funds, TransactionReasons.None);

            // Notify player that a review is available
            ReviewToastView Toast = new ReviewToastView(Rev);

            // Save the instance and game
            StateFundingGlobal.fetch.InstanceConf.saveInstance(Inst);
            GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);

            Debug.Log("Generated Review");
        }
Пример #3
0
        private static void SaveGame(string seed, string filename, string subfolder = "", bool printVessels = true)
        {
            // Expand subfolder
            if (subfolder == "")
            {
                subfolder = HighLogic.SaveFolder;
            }
            else
            {
                subfolder = Path.Combine(HighLogic.SaveFolder, subfolder);
            }
            // Make sure everyone is on the same page
            Game savedGame = HighLogic.CurrentGame.Updated();

            GamePersistence.SaveGame(savedGame, filename, subfolder, SaveMode.OVERWRITE);
            // Log all vessels in the current seed
            if (printVessels)
            {
                Debugger.Log("Vessels in save " + seed + ":");
            }
            foreach (ProtoVessel v in HighLogic.CurrentGame.flightState.protoVessels)
            {
                if (printVessels)
                {
                    Debugger.Log(v.vesselName);
                }
                // All this does is makes sure all the loaded vessels are internally set to the new seed
                VesselManager.LoadPersistentVessel(seed, v);
            }
            ForceTrackingStationUpdate();
        }
Пример #4
0
 void gotoSPH()
 {
     ClearSpaceCenter();
     GamePersistence.SaveGame(SaveGame, HighLogic.SaveFolder, SaveMode.OVERWRITE);
     //            StartCoroutine(loadScene(GameScenes.EDITOR, EditorFacility.SPH));
     loadScene(GameScenes.EDITOR, EditorFacility.SPH);
 }
Пример #5
0
        public void TechDisableEventFinal(bool save = false)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(TechDisableEventFinal);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (KCT_PresetManager.Instance != null && KCT_PresetManager.Instance.ActivePreset != null)
                {
                    if (KCT_PresetManager.Instance.ActivePreset.generalSettings.TechUnlockTimes && KCT_PresetManager.Instance.ActivePreset.generalSettings.BuildTimes)
                    {
                        foreach (KCT_TechItem tech in GameStates.TechList)
                        {
                            /* foreach (String partName in tech.UnlockedParts)
                             * {
                             *   AvailablePart expt = KCT_Utilities.GetAvailablePartByName(partName);
                             *   if (expt != null && ResearchAndDevelopment.IsExperimentalPart(expt))
                             *       if (!KCT_GameStates.ExperimentalParts.Contains(expt))
                             *           KCT_GameStates.ExperimentalParts.Add(expt);
                             * }*/
                            //ResearchAndDevelopment.AddExperimentalPart()
                            tech.DisableTech();
                        }

                        /*    foreach (AvailablePart expt in KCT_GameStates.ExperimentalParts)
                         *      ResearchAndDevelopment.AddExperimentalPart(expt);*/
                        //Need to somehow update the R&D instance
                        if (save)
                        {
                            GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                        }
                    }
                }
            }
        }
Пример #6
0
 public void VersionCheck(int kspMajor, int kspMinor, int kspRev, int kestrel)
 {
     if (Network.isServer)
     {
         print("Warning: VersionCheck called on server");
         return;
     }
     if (FlightState.lastCompatibleMajor != kspMajor || FlightState.lastCompatibleMinor != kspMinor || FlightState.lastCompatibleRev != kspRev)
     {
         ErrorPopup.Error("Incompatible KSP versions, disconnected");
         print("Incompatible KSP versions\nMine: " + FlightState.lastCompatibleMajor + "." + FlightState.lastCompatibleMinor + "." + FlightState.lastCompatibleRev + "\nTheirs: " + kspMajor + "." + kspMinor + "." + kspRev);
         Network.Disconnect(200);
     }
     else if (NetworkVersion != kestrel)
     {
         ErrorPopup.Error("Incompatible Kestrel versions, disconnected");
         print("Incompatible Kestrel versions\nMine: " + NetworkVersion + "\nTheirs: " + kestrel);
         Network.Disconnect(200);
     }
     else
     {
         print("Saving : " + GamePersistence.SaveGame("kestrel", HighLogic.SaveFolder, SaveMode.OVERWRITE));
         foreach (var vessel in FlightGlobals.Vessels.ToArray())
         {
             vessel.Die();
         }
         networkView.RPC("Handshake", RPCMode.Server);
     }
 }
Пример #7
0
        protected void addFlightExperience()
        {
            string partTitle = string.Empty;

            for (int index = 0; index < qualityControlModules.Length; index++)
            {
                //Get the part title
                partTitle = qualityControlModules[index].part.partInfo.title;

                //Record the flight experience.
                BARISScenario.Instance.RecordFlightExperience(qualityControlModules[index].part, BARISSettingsLaunch.FlightsPerQualityBonus * experienceModifier);

                //Calculate the new quality rating.
                int    totalQuality = qualityControlModules[index].quality + BARISScenario.Instance.GetFlightBonus(qualityControlModules[index].part);
                string message      = partTitle + " " + BARISScenario.QualityLabel + totalQuality;

                //Inform the user.
                ScreenMessages.PostScreenMessage(message, BARISScenario.MessageDuration, ScreenMessageStyle.UPPER_CENTER);
            }

            //Don't forget to update the editor bays
            BARISScenario.Instance.UpdateEditorBayFlightBonuses();

            //Save the game
            GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
        }
Пример #8
0
        private void OnCraftLaunch()
        {
            var game     = GamePersistence.LoadGame(FlightDriver.StateFileToLoad, HighLogic.SaveFolder, true, true);
            var vesselid = game.flightState.protoVessels.FindIndex(v => v.vesselID.Equals(Vesselid));
            var vessel   = game.flightState.protoVessels[vesselid];

            foreach (var crewMember in vessel.GetVesselCrew())
            {
                var part = EditorLogic.fetch.ship.parts.Find(p => p.protoModuleCrew.Count < p.CrewCapacity);
                if (part == null)
                {
                    Debug.LogWarning("We dit not had enough space for this kerbal");
                }
                else
                {
                    part.AddCrewmemberAt(crewMember, part.protoModuleCrew.Count);
                }
            }

            var newVessel = GetVesselFromShipConstruct(EditorLogic.fetch.ship, vessel, game);

            vessel.protoPartSnapshots = newVessel.protoPartSnapshots;

            GamePersistence.SaveGame(game, FlightDriver.StateFileToLoad, HighLogic.SaveFolder, SaveMode.OVERWRITE);
            FlightDriver.StartAndFocusVessel(game, vesselid);
            Debug.Log("Editing Vessel and switching to it");
        }
Пример #9
0
 public static void Save()
 {
     //if (GameManager.IsPlayerAlive)
     {
         GamePersistence.SaveGame(GameSaveName);
     }
 }
Пример #10
0
 public static void SetLastMissionData(this ProtoCrewMember kerbal, double newMissionDuration, double currentTime)
 {
     Logging.Debug("RosterExtensions.SetLastMissionData");
     CrewRandRRoster.Instance.GetExtForKerbal(kerbal).LastMissionDuration = newMissionDuration;
     CrewRandRRoster.Instance.GetExtForKerbal(kerbal).LastMissionEndTime  = currentTime;
     GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
 }
Пример #11
0
        public static void JumpToVessel(Vessel v)
        {
            string _saveGame = GamePersistence.SaveGame("Goto_" + version.ToString(), HighLogic.SaveFolder, SaveMode.OVERWRITE);

            // Keep until 3 backups of Goto
            if (version++ > 3)
            {
                version = 0;
            }

            if (Lib.IsFlight())
            {
                FlightGlobals.SetActiveVessel(v);
            }
            else
            {
                int _idx = HighLogic.CurrentGame.flightState.protoVessels.FindLastIndex(pv => pv.vesselID == v.id);

                if (_idx != -1)
                {
                    FlightDriver.StartAndFocusVessel(_saveGame, _idx);
                }
                else
                {
                    Lib.Log("Invalid vessel Id:" + _idx);
                }
            }
        }
Пример #12
0
        internal static void DoQuicksave(string template, string message)
        {
            if (HighLogic.LoadedScene == GameScenes.SPACECENTER ||
                HighLogic.LoadedScene == GameScenes.EDITOR ||
                HighLogic.LoadedScene == GameScenes.FLIGHT ||
                HighLogic.LoadedScene == GameScenes.TRACKSTATION)
            {
                string newName = StringTranslation.AddFormatInfo(template, "", dateFormat);
                if (newName != null && newName.Length > 0)
                {
                    // First we need to acquire the current game status
                    Game currentGame = HighLogic.CurrentGame.Updated();

                    // If we are not at the space center, we have to reset the startScene to flight,
                    // because calling Updated() sets it to space center.
                    if (HighLogic.LoadedScene == GameScenes.FLIGHT)
                    {
                        currentGame.startScene = GameScenes.FLIGHT;
                    }

                    string filename = GamePersistence.SaveGame(currentGame, newName, HighLogic.SaveFolder, SaveMode.OVERWRITE);

                    lastBackup = Time.realtimeSinceStartup;

                    ScreenMessages.PostScreenMessage(message + ": " + newName);
                }

                QuicksaveCleanup.Cleanup();
            }
        }
Пример #13
0
        // Activates the Simulation. Returns the success of the activation.
        public static bool Activate()
        {
            // for recording save status, not sure what this string actually is tbh
            string save = null;

            // Make sure the instance actually exists. I can't imagine this ever failing, but NREs are bad.
            if (instance != null)
            {
                // We create the pre-sim save.
                save = GamePersistence.SaveGame("HoloDeckRevert", HighLogic.SaveFolder, SaveMode.OVERWRITE);

                // Mark the existing save as dirty.
                HoloDeck.instance.SimulationActive = true;

                // Record the scene we are coming from
                HoloDeckShelter.lastScene = HighLogic.LoadedScene;

                if (HoloDeckShelter.lastScene == GameScenes.EDITOR)
                {
                    HoloDeck.OnLeavingEditor(EditorDriver.editorFacility, EditorLogic.fetch.launchSiteName);
                }

                // Start the tell-tale
                HoloDeck.instance.SimulationNotification(true);
            }

            return(save != null ? true : false);
        }
        public GoldStrikeLode AddLode(int planetID, string biome, double longitude, double lattitude, double altitude, string resourceName, double amountRemaining)
        {
            GoldStrikeLode lode = new GoldStrikeLode();
            Dictionary <string, GoldStrikeLode> lodeMap = null;
            string planetBiomeKey = planetID.ToString() + biome;
            string lodeKey        = longitude.ToString() + lattitude.ToString() + resourceName;

            //Setup the new lode
            lode.resourceName    = resourceName;
            lode.longitude       = longitude;
            lode.lattitude       = lattitude;
            lode.biome           = biome;
            lode.amountRemaining = amountRemaining;
            lode.planetID        = planetID;

            //Get the lode map
            if (goldStrikeLodes.ContainsKey(planetBiomeKey) == false)
            {
                lodeMap = new Dictionary <string, GoldStrikeLode>();
                goldStrikeLodes.Add(planetBiomeKey, lodeMap);
            }
            lodeMap = goldStrikeLodes[planetBiomeKey];

            //Add the new lode
            lodeMap.Add(lodeKey, lode);
            goldStrikeLodes[planetBiomeKey] = lodeMap;
            debugLog("Added new lode: " + lode.ToString());

            //Save the game
            GamePersistence.SaveGame("quicksave", HighLogic.SaveFolder, SaveMode.BACKUP);

            return(lode);
        }
Пример #15
0
        private void StartGame()
        {
            //Create new game object for our DMP session.
            HighLogic.CurrentGame = CreateBlankGame();

            //Set the game mode
            HighLogic.CurrentGame.Mode = ConvertGameMode(dmpGame.gameMode);

            //Set difficulty
            HighLogic.CurrentGame.Parameters = dmpGame.serverParameters;

            //Set universe time
            HighLogic.CurrentGame.flightState.universalTime = dmpGame.timeSyncer.GetUniverseTime();
            //Load DMP stuff
            dmpGame.vesselWorker.LoadKerbalsIntoGame();
            dmpGame.vesselWorker.LoadVesselsIntoGame();

            //Load the scenarios from the server
            dmpGame.scenarioWorker.LoadScenarioDataIntoGame();

            //Load the missing scenarios as well (Eg, Contracts and stuff for career mode
            dmpGame.scenarioWorker.LoadMissingScenarioDataIntoGame();

            //This only makes KSP complain
            HighLogic.CurrentGame.CrewRoster.ValidateAssignments(HighLogic.CurrentGame);
            DarkLog.Debug("Starting " + dmpGame.gameMode + " game...");

            //.Start() seems to stupidly .Load() somewhere - Let's overwrite it so it loads correctly.
            GamePersistence.SaveGame(HighLogic.CurrentGame, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            HighLogic.CurrentGame.Start();
            dmpGame.chatWorker.display = true;
            DarkLog.Debug("Started!");
        }
Пример #16
0
        public void StartGame()
        {
            string     SaveDirectory = Path.Combine(KSPUtil.ApplicationRootPath, Path.Combine("saves", "L.O.G"));
            ConfigNode Node          = ConfigNode.Load(Path.Combine(SaveDirectory, "persistent.sfs"));

            HighLogic.CurrentGame             = new Game(Node);
            HighLogic.CurrentGame.Mode        = Game.Modes.SANDBOX;
            HighLogic.CurrentGame.Title       = "L.O.G.";
            HighLogic.CurrentGame.Description = "L.O.G. - Multiplayer";
            HighLogic.CurrentGame.startScene  = GameScenes.SPACECENTER;
            HighLogic.CurrentGame.CrewRoster  = KerbalRoster.GenerateInitialCrewRoster(Game.Modes.SANDBOX);
            Planetarium.SetUniversalTime(0.0);

            if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)
            {
                HighLogic.CurrentGame.Parameters.Difficulty.AllowStockVessels = true;
            }

            HighLogic.CurrentGame.additionalSystems = new ConfigNode();
            HighLogic.CurrentGame.additionalSystems.AddNode("MESSAGESYSTEM");

            HighLogic.CurrentGame.flightState = new FlightState();
            HighLogic.CurrentGame.CrewRoster.ValidateAssignments(HighLogic.CurrentGame);

            HighLogic.SaveFolder = "L.O.G";
            GamePersistence.SaveGame(HighLogic.CurrentGame, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            HighLogic.CurrentGame.Start();

            this.m_playerModel.GameStarted = true;
        }
Пример #17
0
 public void LastVessel()
 {
     SavedGoTo = GoTo.None;
     if (CanLastVessel)
     {
         int   _index      = -1;
         QData _lastVessel = LastVesselLastIndex(out _index);
         if (_lastVessel != null)
         {
             int _idx = _lastVessel.idx;
             if (_idx != -1)
             {
                 ClearSpaceCenter();
                 string _saveGame = GamePersistence.SaveGame(SaveGame, HighLogic.SaveFolder, SaveMode.OVERWRITE);
                 Log(GetText(GoTo.LastVessel));
                 FlightDriver.StartAndFocusVessel(_saveGame, _idx);
                 InputLockManager.ClearControlLocks();
                 LastVessels.RemoveAt(_index);
                 Warning("Remove from the last Vessels: " + _lastVessel.protoVessel.vesselName, "QGoTo");
                 return;
             }
         }
     }
     Warning("You can't " + GetText(GoTo.LastVessel), "QGoTo");
     ScreenMessages.PostScreenMessage("You can't " + GetText(GoTo.LastVessel), 10, ScreenMessageStyle.UPPER_RIGHT);
 }
Пример #18
0
        protected void addFlightExperience()
        {
            List <ModuleQualityControl> qualityModules = FlightGlobals.ActiveVessel.FindPartModulesImplementing <ModuleQualityControl>();

            foreach (ModuleQualityControl qualityModule in qualityModules)
            {
                //Add flight experience
                BARISScenario.Instance.RecordFlightExperience(qualityModule.part, 5);

                //Now recalcuate quality
                qualityModule.flightExperienceBonus = BARISScenario.Instance.GetFlightBonus(qualityModule.part);
                qualityModule.quality        = qualityModule.GetMaxQuality();
                qualityModule.currentQuality = qualityModule.quality;
                qualityModule.UpdateQualityDisplay(BARISScenario.GetConditionSummary(qualityModule.currentMTBF, qualityModule.MaxMTBF, qualityModule.currentQuality, qualityModule.quality));
                debugLog(qualityModule.part.partInfo.title + " Flight Experience: " + qualityModule.flightExperienceBonus + " New Quality: " + qualityModule.quality);
            }

            //Update editor bays
            BARISScenario.Instance.UpdateEditorBayFlightBonuses();

            //Update the cache
            UpdateCachedData();

            //Save the game
            GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
        }
Пример #19
0
        void menuWindow(int windowID)
        {
            GUILayout.BeginVertical();
            if (GUILayout.Button("buy a new ship", HighLogic.Skin.button))
            {
                craftBrowser = LoadCraftDialog.Create(EditorFacility.VAB, HighLogic.CurrentGame.Title.Split(new string[] { " (" }, StringSplitOptions.None)[0], OnSelected, OnCancelled, false);
                MenuWindow   = false;
            }
            if (GUILayout.Button("Sell a ship", HighLogic.Skin.button))
            {
                MenuWindow = false;
                sellWindow = true;
            }
            if (GUILayout.Button("Design a new ship", HighLogic.Skin.button))
            {
                MenuWindow  = false;
                sellWindow  = false;
                aboutWindow = false;
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.BACKUP);
                EditorDriver.StartEditor(EditorFacility.VAB);
            }
            if (GUILayout.Button("close", HighLogic.Skin.button))
            {
                MenuWindow          = false;
                MainMenu.menuWindow = true;
            }

            GUILayout.EndVertical();
        }
Пример #20
0
        protected void addFlightExperience()
        {
            if (EditorLogic.fetch.ship.parts.Count == 0)
            {
                BARISScenario.Instance.LogPlayerMessage("Load a vessel before trying to add flight experience.");
                return;
            }

            Part[] parts = EditorLogic.fetch.ship.parts.ToArray();
            ModuleQualityControl qualityControl;

            foreach (Part part in parts)
            {
                qualityControl = part.FindModuleImplementing <ModuleQualityControl>();
                if (qualityControl != null)
                {
                    BARISScenario.Instance.RecordFlightExperience(part, 5);
                }
            }

            //Update editor bays
            BARISScenario.Instance.UpdateEditorBayFlightBonuses();

            //Save the game
            GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
        }
        void DisplayTravelBugData(System.Guid vesselID, string vesselName, string keoCacheName, string keoCacheTitle)
        {
            GUILayout.BeginHorizontal();
            GUILayout.TextField(vesselName, GUILayout.Width(175));
            GUILayout.Space(5);
            GUILayout.TextField(keoCacheName, GUILayout.Width(175));
            GUILayout.Space(5);
            GUILayout.TextField(keoCacheTitle, GUILayout.Width(175));
            GUILayout.Space(5);
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Select", GUILayout.Width(55)))
            {
                visibleTravelBug = false;

                string _saveGame = GamePersistence.SaveGame(SaveGame, HighLogic.SaveFolder, SaveMode.OVERWRITE);

                int _idx = HighLogic.CurrentGame.flightState.protoVessels.FindLastIndex(pv => pv.vesselID == vesselID);
                if (_idx != -1)
                {
                    FlightDriver.StartAndFocusVessel(_saveGame, _idx);
                }
                else
                {
                    //QDebug.Warning("QStart: invalid idx", "QSpaceCenter");
//DestroyThis();
                }
            }
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
        }
Пример #22
0
        private void StartGame()
        {
            //Create new game object for our DMP session.
            HighLogic.CurrentGame = CreateBlankGame();

            //Set the game mode
            SetGameMode();

            //Found in KSP's files. Makes a crapton of sense :)
            if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX)
            {
                HighLogic.CurrentGame.Parameters.Difficulty.AllowStockVessels = false;
            }
            HighLogic.CurrentGame.flightState.universalTime = TimeSyncer.fetch.GetUniverseTime();

            //Load DMP stuff
            VesselWorker.fetch.LoadKerbalsIntoGame();
            VesselWorker.fetch.LoadVesselsIntoGame();

            //Load the scenarios from the server
            ScenarioWorker.fetch.LoadScenarioDataIntoGame();

            //Load the missing scenarios as well (Eg, Contracts and stuff for career mode
            ScenarioWorker.fetch.LoadMissingScenarioDataIntoGame();

            //This only makes KSP complain
            HighLogic.CurrentGame.CrewRoster.ValidateAssignments(HighLogic.CurrentGame);
            DarkLog.Debug("Starting " + gameMode + " game...");

            //.Start() seems to stupidly .Load() somewhere - Let's overwrite it so it loads correctly.
            GamePersistence.SaveGame(HighLogic.CurrentGame, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            HighLogic.CurrentGame.Start();
            ChatWorker.fetch.display = true;
            DarkLog.Debug("Started!");
        }
Пример #23
0
        private void StartGameNow()
        {
            //Create new game object for our LMP session.
            HighLogic.CurrentGame = CreateBlankGame();

            //Set the game mode
            HighLogic.CurrentGame.Mode = ConvertGameMode(SettingsSystem.ServerSettings.GameMode);

            //Set difficulty
            HighLogic.CurrentGame.Parameters = SettingsSystem.ServerSettings.ServerParameters;
            SetAdvancedAndCommNetParams(HighLogic.CurrentGame);

            //Set universe time
            HighLogic.CurrentGame.flightState.universalTime = WarpSystem.Singleton.GetCurrentSubspaceTime();

            //Load LMP stuff
            KerbalSystem.Singleton.LoadKerbalsIntoGame();
            VesselProtoSystem.Singleton.VesselLoader.LoadVesselsIntoGame();

            //Load the scenarios from the server
            ScenarioSystem.Singleton.LoadScenarioDataIntoGame();

            //Load the missing scenarios as well (Eg, Contracts and stuff for career mode
            ScenarioSystem.Singleton.LoadMissingScenarioDataIntoGame();

            //This only makes KSP complain
            HighLogic.CurrentGame.CrewRoster.ValidateAssignments(HighLogic.CurrentGame);
            Debug.Log("[LMP]: Starting " + SettingsSystem.ServerSettings.GameMode + " game...");

            //.Start() seems to stupidly .Load() somewhere - Let's overwrite it so it loads correctly.
            GamePersistence.SaveGame(HighLogic.CurrentGame, "persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            HighLogic.CurrentGame.Start();
            Debug.Log("[LMP]: Started!");
        }
Пример #24
0
        protected void registerRepairProject(UnloadedQualitySummary qualitySummary)
        {
            //Show tooltip: The repair attempt might not suceed!
            if (!BARISScenario.showedRepairProjectTip && BARISScenario.partsCanBreak)
            {
                BARISScenario.showedRepairProjectTip = true;
                BARISEventCardView cardView = new BARISEventCardView();

                cardView.WindowTitle = BARISScenario.RepairProjectTitle;
                cardView.description = BARISScenario.RepairProjectMsg;
                cardView.imagePath   = BARISScenario.RepairProjectImagePath;

                cardView.SetVisible(true);
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            }

            //Create repair project
            BARISRepairProject repairProject = new BARISRepairProject();

            repairProject.vesselID          = qualitySummary.vessel.id.ToString();
            repairProject.repairCostFunds   = qualitySummary.repairCostFunds;
            repairProject.repairCostScience = qualitySummary.repairCostScience;
            repairProject.repairCostTime    = qualitySummary.repairCostTime;
            repairProject.startTime         = Planetarium.GetUniversalTime();

            //Register the project
            BARISScenario.Instance.RegisterRepairProject(repairProject);
        }
Пример #25
0
        public string SaveGame(string func, string saveFileName, string saveFolder, SaveMode saveMode)
        {
            saveInProgress = true;
            Log.Info("Save: SaveGame 2: " + func);

            return(GamePersistence.SaveGame(saveFileName, saveFolder, saveMode));
        }
Пример #26
0
 void gotoVAB()
 {
     Log("gotoVAB", "QuickGoTo", true);
     ClearSpaceCenter();
     GamePersistence.SaveGame(SaveGame, HighLogic.SaveFolder, SaveMode.OVERWRITE);
     //            StartCoroutine(loadScene(GameScenes.EDITOR, EditorFacility.VAB));
     loadScene(GameScenes.EDITOR, EditorFacility.VAB);
 }
Пример #27
0
        // static functions, that make live a lot easier

        /// <summary>
        /// Stores a Vessel into the specified Hangar
        /// </summary>
        internal static void StoreVessel(Vessel vessel, Hangar hangar)
        {
            StoredVessel storedVessel = new StoredVessel
            {
                uuid       = vessel.protoVessel.vesselID,
                vesselName = vessel.GetDisplayName()
            };

            //get the experience and assign the crew to the rooster
            foreach (Part part in vessel.parts)
            {
                int count = part.protoModuleCrew.Count;

                if (count != 0)
                {
                    ProtoCrewMember[] crewList = part.protoModuleCrew.ToArray();

                    for (int i = 0; i < count; i++)
                    {
                        crewList[i].flightLog.AddEntryUnique(FlightLog.EntryType.Recover);
                        crewList[i].flightLog.AddEntryUnique(FlightLog.EntryType.Land, FlightGlobals.currentMainBody.name);
                        crewList[i].ArchiveFlightLog();

                        // remove the crew from the ship
                        part.RemoveCrewmember(crewList[i]);
                    }
                }
            }


            // save the ship
            storedVessel.vesselNode = new ConfigNode("VESSEL");

            //create a backup of the current state, then save that state
            ProtoVessel backup = vessel.BackupVessel();

            backup.Save(storedVessel.vesselNode);

            // save the stored information in the hangar
            hangar.storedVessels.Add(storedVessel);

            // remove the stored vessel from the game
            vessel.MakeInactive();
            vessel.Unload();
            //vessel.Die();

            FlightGlobals.RemoveVessel(vessel);
            if (vessel != null)
            {
                vessel.protoVessel.Clean();
            }

            //UnityEngine.Object.Destroy(vessel.gameObject);

            GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            HighLogic.LoadScene(GameScenes.SPACECENTER);
        }
Пример #28
0
        void mainMenuWindow(int windowID)
        {
            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(TradingButton, HighLogic.Skin.button))
            {
                trading.checkPrice(vessel.orbit.referenceBody.name, vessel.orbit.semiMajorAxis);
                menuWindow            = false;
                trading.DrawGUIWindow = true;
            }
            if (GUILayout.Button(CrewHireButton, HighLogic.Skin.button))
            {
                menuWindow = false;
                crewHire.GenerateCrew();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(AsteroidButton, HighLogic.Skin.button))
            {
                menuWindow           = false;
                asteroid.asteroidGUI = true;
            }

            if (GUILayout.Button(ShipShopButton, HighLogic.Skin.button))
            {
                menuWindow          = false;
                shipShop.MenuWindow = true;
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(ExplorationButton, HighLogic.Skin.button))
            {
                menuWindow             = false;
                exploration.infoWindow = true;
            }
            if (GUILayout.Button(Contract, HighLogic.Skin.button))
            {
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.BACKUP);
                HighLogic.LoadScene(GameScenes.SPACECENTER);
                menuWindow = false;
            }
            if (part.partInfo.name == "pirateStationScreen")
            {
                if (GUILayout.Button(SlaveTrafficButton, HighLogic.Skin.button))
                {
                    slavesTraffic.CheckPrice(vessel.mainBody.name);
                    menuWindow = false;
                    slavesTraffic.slaveWindow = true;
                }
            }
            GUILayout.EndHorizontal();
            if (GUILayout.Button("close", HighLogic.Skin.button))
            {
                menuWindow = false;
            }
            GUILayout.EndVertical();
        }
Пример #29
0
 private void StopGame()
 {
     HighLogic.SaveFolder = "DarkMultiPlayer";
     GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
     if (HighLogic.LoadedScene != GameScenes.MAINMENU)
     {
         HighLogic.LoadScene(GameScenes.MAINMENU);
     }
 }
Пример #30
0
        public void GameSceneEvent(GameScenes scene)
        {
            KCT_GUI.HideAll();

            if (scene == GameScenes.MAINMENU)
            {
                KCTGameStates.Reset();
                KCTGameStates.IsFirstStart = false;
                InputLockManager.RemoveControlLock("KCTLaunchLock");
                KCTGameStates.ActiveKSCName = Utilities._defaultKscId;
                KCTGameStates.ActiveKSC     = new KSCItem(Utilities._defaultKscId);
                KCTGameStates.KSCs          = new List <KSCItem>()
                {
                    KCTGameStates.ActiveKSC
                };
                KCTGameStates.LastKnownTechCount = 0;

                if (PresetManager.Instance != null)
                {
                    PresetManager.Instance.ClearPresets();
                    PresetManager.Instance = null;
                }

                return;
            }

            KCTGameStates.MiscellaneousTempUpgrades = 0;

            if (PresetManager.PresetLoaded() && !PresetManager.Instance.ActivePreset.GeneralSettings.Enabled)
            {
                return;
            }
            var validScenes = new List <GameScenes> {
                GameScenes.SPACECENTER, GameScenes.TRACKSTATION, GameScenes.EDITOR
            };

            if (validScenes.Contains(scene))
            {
                TechDisableEventFinal();
            }

            if (HighLogic.LoadedScene == scene && scene == GameScenes.EDITOR)    //Fix for null reference when using new or load buttons in editor
            {
                GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
            }

            if (HighLogic.LoadedSceneIsEditor)
            {
                EditorLogic.fetch.Unlock("KCTEditorMouseLock");
            }

            if (scene == GameScenes.EDITOR && !HighLogic.LoadedSceneIsEditor)
            {
                KCT_GUI.FirstOnGUIUpdate = true;
            }
        }