public void LoadScenarioDataIntoGame() { while (scenarioQueue.Count > 0) { ScenarioEntry scenarioEntry = scenarioQueue.Dequeue(); if (scenarioEntry.scenarioName == "ContractSystem") { RemoveKerbalRescueMissionsSoTheGameDoesntBugOut(scenarioEntry.scenarioNode); } if (scenarioEntry.scenarioName == "ProgressTracking") { CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(scenarioEntry.scenarioNode); } ProtoScenarioModule psm = new ProtoScenarioModule(scenarioEntry.scenarioNode); if (psm != null) { if (IsScenarioModuleAllowed(psm.moduleName)) { DarkLog.Debug("Loading " + psm.moduleName + " scenario data"); HighLogic.CurrentGame.scenarios.Add(psm); } else { DarkLog.Debug("Skipping " + psm.moduleName + " scenario data in " + Client.fetch.gameMode + " mode"); } } } }
public void LoadScenarioDataIntoGame() { lock (scenarioQueue) { while (scenarioQueue.Count > 0) { ScenarioEntry scenarioEntry = scenarioQueue.Dequeue(); if (scenarioEntry.scenarioName == "ProgressTracking") { CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(scenarioEntry.scenarioNode); } CheckForBlankSceneSoTheGameDoesntBugOut(scenarioEntry); ProtoScenarioModule psm = new ProtoScenarioModule(scenarioEntry.scenarioNode); if (psm != null) { if (IsScenarioModuleAllowed(psm.moduleName)) { DarkLog.Debug("Loading " + psm.moduleName + " scenario data"); HighLogic.CurrentGame.scenarios.Add(psm); ByteArray scenarioHashBytes = configNodeSerializer.Serialize(scenarioEntry.scenarioNode); checkData[scenarioEntry.scenarioName] = Common.CalculateSHA256Hash(scenarioHashBytes); ByteRecycler.ReleaseObject(scenarioHashBytes); } else { DarkLog.Debug("Skipping " + psm.moduleName + " scenario data in " + dmpGame.gameMode + " mode"); } } } } }
private void Start() { var currentgame = HighLogic.CurrentGame; Utilities.Log("AmpYear AddScenarioModules ScenarioModules Start"); ProtoScenarioModule protoscenmod = currentgame.scenarios.Find(s => s.moduleName == typeof(AmpYear).Name); if (protoscenmod == null) { Utilities.Log("AmpYear AddScenarioModules Adding the scenario module."); protoscenmod = currentgame.AddProtoScenarioModule(typeof(AmpYear), GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.EDITOR); } else { if (protoscenmod.targetScenes.All(s => s != GameScenes.SPACECENTER)) { Utilities.Log("AmpYear AddScenarioModules Adding the SpaceCenter scenario module."); protoscenmod.targetScenes.Add(GameScenes.SPACECENTER); } if (protoscenmod.targetScenes.All(s => s != GameScenes.FLIGHT)) { Utilities.Log("AmpYear AddScenarioModules Adding the flight scenario module."); protoscenmod.targetScenes.Add(GameScenes.FLIGHT); } if (protoscenmod.targetScenes.All(s => s != GameScenes.EDITOR)) { Utilities.Log("AmpYear AddScenarioModules Adding the Editor scenario module."); protoscenmod.targetScenes.Add(GameScenes.EDITOR); } } }
void Start() { var game = HighLogic.CurrentGame; ProtoScenarioModule psm = game.scenarios.Find(s => s.moduleName == typeof(TacLifeSupport).Name); if (psm == null) { this.Log("Adding the scenario module."); psm = game.AddProtoScenarioModule(typeof(TacLifeSupport), GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.EDITOR, GameScenes.SPH); } else { if (!psm.targetScenes.Any(s => s == GameScenes.SPACECENTER)) { psm.targetScenes.Add(GameScenes.SPACECENTER); } if (!psm.targetScenes.Any(s => s == GameScenes.FLIGHT)) { psm.targetScenes.Add(GameScenes.FLIGHT); } if (!psm.targetScenes.Any(s => s == GameScenes.EDITOR)) { psm.targetScenes.Add(GameScenes.EDITOR); } if (!psm.targetScenes.Any(s => s == GameScenes.SPH)) { psm.targetScenes.Add(GameScenes.SPH); } } }
private static void SetTargetScene(ProtoScenarioModule psm, GameScenes scene) { if (!psm.targetScenes.Any(s => s == scene)) { psm.targetScenes.Add(scene); } }
public void LoadScenarioDataIntoGame() { while (scenarioQueue.Count > 0) { ScenarioEntry scenarioEntry = scenarioQueue.Dequeue(); if (scenarioEntry.scenarioName == "ProgressTracking") { CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(scenarioEntry.scenarioNode); } CheckForBlankSceneSoTheGameDoesntBugOut(scenarioEntry); ProtoScenarioModule psm = new ProtoScenarioModule(scenarioEntry.scenarioNode); if (psm != null) { if (IsScenarioModuleAllowed(psm.moduleName)) { DarkLog.Debug("Loading " + psm.moduleName + " scenario data"); HighLogic.CurrentGame.scenarios.Add(psm); } else { DarkLog.Debug("Skipping " + psm.moduleName + " scenario data in " + dmpGame.gameMode + " mode"); } } } }
public void LoadScenarioDataIntoGame() { while (ScenarioQueue.TryDequeue(out var scenarioEntry)) { if (scenarioEntry.ScenarioModule == "ContractSystem") { SpawnStrandedKerbalsForRescueMissions(scenarioEntry.ScenarioNode); CreateMissingTourists(scenarioEntry.ScenarioNode); } if (scenarioEntry.ScenarioModule == "ProgressTracking") { CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(scenarioEntry.ScenarioNode); } CheckForBlankSceneSoTheGameDoesntBugOut(scenarioEntry); var psm = new ProtoScenarioModule(scenarioEntry.ScenarioNode); if (IsScenarioModuleAllowed(psm.moduleName) && !IgnoredScenarios.IgnoreReceive.Contains(psm.moduleName)) { LunaLog.Log($"[LMP]: Loading {psm.moduleName} scenario data"); HighLogic.CurrentGame.scenarios.Add(psm); } else { LunaLog.Log($"[LMP]: Skipping {psm.moduleName} scenario data in {SettingsSystem.ServerSettings.GameMode} mode"); } } }
void Start() { var game = HighLogic.CurrentGame; ProtoScenarioModule psm = game.scenarios.Find(s => s.moduleName == typeof(KeepFitScenarioModule).Name); if (psm == null) { this.Log_DebugOnly("Start", "Adding the scenario module."); psm = game.AddProtoScenarioModule(typeof(KeepFitScenarioModule), GameScenes.SPACECENTER, GameScenes.TRACKSTATION, GameScenes.FLIGHT, GameScenes.EDITOR); } else { if (!psm.targetScenes.Any(s => s == GameScenes.SPACECENTER)) { psm.targetScenes.Add(GameScenes.SPACECENTER); } if (!psm.targetScenes.Any(s => s == GameScenes.TRACKSTATION)) { psm.targetScenes.Add(GameScenes.TRACKSTATION); } if (!psm.targetScenes.Any(s => s == GameScenes.FLIGHT)) { psm.targetScenes.Add(GameScenes.FLIGHT); } if (!psm.targetScenes.Any(s => s == GameScenes.EDITOR)) { psm.targetScenes.Add(GameScenes.EDITOR); } } }
public void LoadAsteroidScenario() { ConfigNode asteroidNode = GetAsteroidModuleNode(); ProtoScenarioModule asteroidModule = new ProtoScenarioModule(asteroidNode); HighLogic.CurrentGame.scenarios.Add(asteroidModule); asteroidModule.Load(ScenarioRunner.fetch); }
void Start() { var game = HighLogic.CurrentGame; ProtoScenarioModule psm = game.scenarios.Find(s => s.moduleName == typeof(DangIt).Name); if (psm == null) { Debug.Log("[DangIt]: Adding the controller to the game."); psm = game.AddProtoScenarioModule(typeof(DangIt), GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.SPH, GameScenes.TRACKSTATION); } else // make sure the scenario is targeting all the scenes { Debug.Log("[DangIt]: The runtime is already installed (OK)."); SetTargetScene(psm, GameScenes.EDITOR); SetTargetScene(psm, GameScenes.FLIGHT); SetTargetScene(psm, GameScenes.SPACECENTER); SetTargetScene(psm, GameScenes.SPH); SetTargetScene(psm, GameScenes.TRACKSTATION); } }
private static void SetTargetScene(ProtoScenarioModule psm, GameScenes scene) { if (!psm.targetScenes.Any(s => s == scene)) { psm.targetScenes.Add(scene); } }
public static void CreateSettings(Game game) { if (!game.scenarios.Any(p => p.moduleName == typeof(LastKSC).Name)) { ProtoScenarioModule proto = game.AddProtoScenarioModule(typeof(LastKSC), GameScenes.TRACKSTATION); proto.Load(ScenarioRunner.fetch); } }
public void LoadAsteroidScenario() { ConfigNode asteroidNode = GetAsteroidModuleNode(); ProtoScenarioModule asteroidModule = new ProtoScenarioModule(asteroidNode); HighLogic.CurrentGame.scenarios.Add(asteroidModule); asteroidModule.Load(ScenarioRunner.fetch); }
internal static void UnloadCommNet(ProtoScenarioModule psm = null) { Debug.Log($"{ModTag} Patching CommNet's TargetScenes"); psm ??= GetCommNetScenarioModule(); if (psm != null) { psm.SetTargetScenes(new GameScenes[] { GameScenes.CREDITS }); } }
public static string DisplayGamescenes(ProtoScenarioModule psm) { string s = string.Empty; foreach (GameScenes gs in psm.targetScenes) { s += $"{gs} "; } return($"{psm} {psm.moduleName} [{s}]"); }
public static string DisplayGamescenes(ProtoScenarioModule psm) { string s = "[ "; foreach (GameScenes gs in psm.targetScenes) { s += string.Format("{0} ", gs); } s += "]"; return(string.Format("{0} {1} {2}", psm, psm.moduleName, s)); }
private void OnGameStateCreated(Game game) { LastKSC.CreateSettings(game); if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { ProtoScenarioModule m = HighLogic.CurrentGame.scenarios.FirstOrDefault(m => m.moduleName == "LastKSC"); if (m == null) { return; } LastKSC l = (LastKSC)m.Load(ScenarioRunner.Instance); bool noSite; if (!string.IsNullOrEmpty(l.lastSite)) { // found a site, load it ConfigNode site = Sites.GetSiteByName(l.lastSite); if (site == null) { l.lastSite = Sites.defaultSite; noSite = true; } else { KSCSwitcher.SetSiteAndResetCamera(site); Debug.Log("KSCSwitcher set the launch site to the last site, " + l.lastSite); return; } } else { l.lastSite = Sites.defaultSite; noSite = true; } if (noSite) { if (!string.IsNullOrEmpty(Sites.defaultSite)) { ConfigNode site = Sites.GetSiteByName(Sites.defaultSite); if (site == null) { Debug.LogError("KSCSwitcher found a default site name but could not retrieve the site config: " + Sites.defaultSite); return; } else { KSCSwitcher.SetSiteAndResetCamera(site); Debug.Log("KSCSwitcher set the initial launch site to the default" + Sites.defaultSite); } } } } }
public void Start() { bool scenarioExists = !HighLogic.CurrentGame.scenarios.All(scenario => scenario.moduleName != typeof(MerillData).Name); if (!scenarioExists) { DontDestroyOnLoad(this); alreadyStarted = true; print("[MERILL] addon start "); me = this; //print("[MERILL] addon start2 "); //print("[MERILL] addon start " + HighLogic.CurrentGame); //print("[MERILL] addon start "); for (int i = 0; i < HighLogic.CurrentGame.scenarios.Count; i++) { ProtoScenarioModule fx = HighLogic.CurrentGame.scenarios[i]; print("[Merill] module partfx: " + HighLogic.CurrentGame.scenarios[i].moduleName + " , type=" + HighLogic.CurrentGame.scenarios[i].GetType()); } //lauch scenario HighLogic.CurrentGame.AddProtoScenarioModule(typeof(MerillData), new GameScenes[] { GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.EDITOR, GameScenes.TRACKSTATION }); //remove not-wanted contract ////Code for saving to the persistence.sfs //ProtoScenarioModule scenario = HighLogic.CurrentGame.scenarios.Find(s => s.moduleName == typeof(MerillData).Name); //if (scenario == null) //{ // try // { // Debug.Log("[MERILL] Adding InternalModule scenario to game '" + HighLogic.CurrentGame.Title + "'"); // HighLogic.CurrentGame.AddProtoScenarioModule(typeof(MerillData), new GameScenes[] { GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.EDITOR, GameScenes.TRACKSTATION }); // // the game will add this scenario to the appropriate persistent file on save from now on // } // catch (ArgumentException ae) // { // Debug.LogException(ae); // } // catch // { // Debug.Log("[MERILL] Unknown failure while adding scenario."); // } //} print("[MERILL] addon instance: " + me + " ? "); } Destroy(this); }
private void getAllTechnologies() { //maj currenttech allTechResearched.Clear(); if (HighLogic.CurrentGame.Mode != Game.Modes.SANDBOX) { ProtoScenarioModule protoScenario = HighLogic.CurrentGame.scenarios.Find(x => x.moduleName == "ResearchAndDevelopment"); foreach (ConfigNode tech in protoScenario.GetData().GetNodes("Tech")) { string node = tech.GetValue("id"); allTechResearched.Add(node); } } }
public void LoadNewScenarioData(ConfigNode newScenarioData) { ProtoScenarioModule newModule = new ProtoScenarioModule(newScenarioData); try { HighLogic.CurrentGame.scenarios.Add(newModule); newModule.Load(ScenarioRunner.fetch); } catch { DarkLog.Debug("Error loading scenario data!"); blockScenarioDataSends = true; } }
public void LoadNewScenarioData(ConfigNode newScenarioData) { ProtoScenarioModule newModule = new ProtoScenarioModule(newScenarioData); try { HighLogic.CurrentGame.scenarios.Add(newModule); newModule.Load(ScenarioRunner.Instance); } catch { DarkLog.Debug("Error loading scenario data!"); blockScenarioDataSends = true; } }
public void LoadScenarioDataIntoGame() { while (ScenarioQueue.TryDequeue(out var scenarioEntry)) { var psm = new ProtoScenarioModule(scenarioEntry.ScenarioNode); if (IsScenarioModuleAllowed(psm.moduleName) && !IgnoredScenarios.IgnoreReceive.Contains(psm.moduleName)) { LunaLog.Log($"[LMP]: Loading {psm.moduleName} scenario data"); HighLogic.CurrentGame.scenarios.Add(psm); } else { LunaLog.Log($"[LMP]: Skipping {psm.moduleName} scenario data in {SettingsSystem.ServerSettings.GameMode} mode"); } } }
public void UpgradeTheAstronautComplexSoTheGameDoesntBugOut() { ProtoScenarioModule sm = HighLogic.CurrentGame.scenarios.Find(psm => psm.moduleName == "ScenarioUpgradeableFacilities"); if (sm != null) { if (ScenarioUpgradeableFacilities.protoUpgradeables.ContainsKey("SpaceCenter/AstronautComplex")) { foreach (Upgradeables.UpgradeableFacility uf in ScenarioUpgradeableFacilities.protoUpgradeables["SpaceCenter/AstronautComplex"].facilityRefs) { DarkLog.Debug("Setting astronaut complex to max level"); uf.SetLevel(uf.MaxLevel); } } } }
private static void installScenario() { Game game = HighLogic.CurrentGame; if ((game != null) && !game.scenarios.Any(s => s.moduleName == typeof(EarnedAchievements).Name)) { // add scenario to game ProtoScenarioModule scenario = game.AddProtoScenarioModule(typeof(EarnedAchievements), GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.TRACKSTATION); // load scenario instantly if (scenario.targetScenes.Contains(HighLogic.LoadedScene)) { scenario.Load(ScenarioRunner.fetch); } } }
private void Initialize() { Instance = this; SaveAbleList.Clear(); KCoopTimer t = new KCoopTimer("KSCtimer", false); timers.Add(t); SaveAbleList.Add(t); t = new KCoopTimer("Flighttimer", false); timers.Add(t); SaveAbleList.Add(t); t = new KCoopTimer("Editortimer", false); timers.Add(t); SaveAbleList.Add(t); //UnityEngine.Object.DontDestroyOnLoad(this); flag_Initialized = true; // add scenario module var game = HighLogic.CurrentGame; ProtoScenarioModule psm = game.scenarios.Find(s => s.moduleName == typeof(KerbalCooperation).Name); if (psm == null) { psm = game.AddProtoScenarioModule(typeof(KerbalCooperation), GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.EDITOR); } else { if (!psm.targetScenes.Any(s => s == GameScenes.SPACECENTER)) { psm.targetScenes.Add(GameScenes.SPACECENTER); } if (!psm.targetScenes.Any(s => s == GameScenes.FLIGHT)) { psm.targetScenes.Add(GameScenes.FLIGHT); } if (!psm.targetScenes.Any(s => s == GameScenes.EDITOR)) { psm.targetScenes.Add(GameScenes.EDITOR); } } }
void Start() { var game = HighLogic.CurrentGame; ProtoScenarioModule psm = game.scenarios.Find(s => s.moduleName == typeof(MapOverlay).Name); if (psm == null) { this.Log("Adding the scenario module."); game.AddProtoScenarioModule(typeof(MapOverlay), GameScenes.FLIGHT); } else { if (psm.targetScenes.All(s => s != GameScenes.FLIGHT)) { psm.targetScenes.Add(GameScenes.FLIGHT); } } }
private void setupScenarioModule() { ProtoScenarioModule protoScenarioModule = HighLogic.CurrentGame.scenarios.FirstOrDefault(i => i.moduleName == typeof (HaystackScenarioModule).Name); if (protoScenarioModule == null) { HSUtils.DebugLog("adding scenario module"); HighLogic.CurrentGame.AddProtoScenarioModule(typeof (HaystackScenarioModule), HaystackScenarioModule.Scenes); } else { var missing = HaystackScenarioModule.Scenes.Except(protoScenarioModule.targetScenes); foreach (var i in missing) { HSUtils.DebugLog("missing scenario module scene: {0}", i); protoScenarioModule.targetScenes.Add(i); } } }
private void InitializePersistence() { LogFormatted_DebugOnly("InitializePersistence()"); // TODO change scenario module name manually so the OATBeanCounterData class can be consistent with the rest of the code ProtoScenarioModule scenario = HighLogic.CurrentGame.scenarios.Find(s => s.moduleName == typeof(OATBeanCounterData).Name); if (scenario == null) { try { LogFormatted("Scenario had no BeanCounter data - Adding to scenario '{0}'", HighLogic.CurrentGame.Title); HighLogic.CurrentGame.AddProtoScenarioModule(typeof(OATBeanCounterData), new GameScenes[] { GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.EDITOR, GameScenes.SPH, GameScenes.TRACKSTATION }); // the game will add this scenario to the appropriate persistent file on save from now on } catch { LogFormatted("Exception while trying to add scenario data"); } } }
private void setupScenarioModule() { ProtoScenarioModule protoScenarioModule = HighLogic.CurrentGame.scenarios.FirstOrDefault(i => i.moduleName == typeof(HaystackScenarioModule).Name); if (protoScenarioModule == null) { Log.dbg("adding scenario module"); HighLogic.CurrentGame.AddProtoScenarioModule(typeof(HaystackScenarioModule), HaystackScenarioModule.Scenes); } else { System.Collections.Generic.IEnumerable <GameScenes> missing = HaystackScenarioModule.Scenes.Except(protoScenarioModule.targetScenes); foreach (GameScenes i in missing) { Log.dbg("missing scenario module scene: {0}", i); protoScenarioModule.targetScenes.Add(i); } } }
public bool needReload() { if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX) { //don't need to reload a sandbox! return(false); } List <string> researchedNow = new List <string>(); researchedNow.AddRange(allTechResearched); ProtoScenarioModule protoScenario = HighLogic.CurrentGame.scenarios.Find(x => x.moduleName == "ResearchAndDevelopment"); foreach (ConfigNode tech in protoScenario.GetData().GetNodes("Tech")) { string node = tech.GetValue("id"); if (allTechResearched.Contains(node)) { researchedNow.Remove(node); } else { //a new researched note! return(true); } } //test if we load a revious save without an actuel tech if (researchedNow.Count == 0) { return(false); } else { return(true); } }
void Start() { var game = HighLogic.CurrentGame; ProtoScenarioModule psm = game.scenarios.Find(s => s.moduleName == typeof(BioMass).Name); if (psm == null) { this.Log_DebugOnly("Adding BioMass to Scenarios"); psm = game.AddProtoScenarioModule(typeof(BioMass), GameScenes.SPACECENTER, GameScenes.FLIGHT); } else { if (!psm.targetScenes.Any(s => s == GameScenes.SPACECENTER)) { psm.targetScenes.Add(GameScenes.SPACECENTER); } if (!psm.targetScenes.Any(s => s == GameScenes.FLIGHT)) { psm.targetScenes.Add(GameScenes.FLIGHT); } } }
public void LoadScenarioDataIntoGame() { while (scenarioQueue.Count > 0) { LoadScenarioData(scenarioQueue.Dequeue()); } if (!loadedScience && Client.fetch.gameMode == GameMode.CAREER) { DarkLog.Debug("Creating new science data"); ConfigNode newNode = GetBlankResearchAndDevelopmentNode(); ProtoScenarioModule newModule = new ProtoScenarioModule(newNode); try { HighLogic.CurrentGame.scenarios.Add(newModule); newModule.Load(ScenarioRunner.fetch); } catch { DarkLog.Debug("Error loading new science data!"); blockScenarioDataSends = true; } } }
void Start() { var game = HighLogic.CurrentGame; ProtoScenarioModule psm = game.scenarios.Find(s => s.moduleName == typeof(PlayYourWay).Name); if (psm == null) { PlayYourWay.Log("Adding the controller to the game."); psm = game.AddProtoScenarioModule(typeof(PlayYourWay), GameScenes.EDITOR, GameScenes.FLIGHT, GameScenes.SPACECENTER, GameScenes.TRACKSTATION); } else { PlayYourWay.Log("The runtime is already installed (OK)."); SetTargetScene(psm, GameScenes.EDITOR); SetTargetScene(psm, GameScenes.FLIGHT); SetTargetScene(psm, GameScenes.SPACECENTER); SetTargetScene(psm, GameScenes.TRACKSTATION); } }
public void LoadScenarioDataIntoGame() { while (scenarioQueue.Count > 0) { ProtoScenarioModule psm = new ProtoScenarioModule(scenarioQueue.Dequeue().scenarioNode); if (psm != null) { if (IsScenarioModuleAllowed(psm.moduleName)) { DarkLog.Debug("Loading " + psm.moduleName + " scenario data"); HighLogic.CurrentGame.scenarios.Add(psm); } else { DarkLog.Debug("Skipping " + psm.moduleName + " scenario data in " + Client.fetch.gameMode + " mode"); } } } }
public void LoadScenarioData(ScenarioEntry entry) { if (entry.scenarioName == "ScenarioDiscoverableObjects") { DarkLog.Debug("Skipping loading asteroid data - It is created locally"); return; } if (entry.scenarioName == "ResearchAndDevelopment" && Client.fetch.gameMode != GameMode.CAREER) { DarkLog.Debug("Skipping loading career mode data in sandbox"); return; } if (entry.scenarioName == "ResearchAndDevelopment" && Client.fetch.gameMode == GameMode.CAREER) { loadedScience = true; } //Don't stare directly at the next 7 lines - It's bad for your eyes. string tempFile = Path.GetTempFileName(); using (StreamWriter sw = new StreamWriter(tempFile)) { sw.Write(entry.scenarioData); } ConfigNode scenarioNode = ConfigNode.Load(tempFile); File.Delete(tempFile); if (scenarioNode == null) { DarkLog.Debug(entry.scenarioName + " scenario data failed to create a ConfigNode!"); blockScenarioDataSends = true; return; } bool loaded = false; foreach (ProtoScenarioModule psm in HighLogic.CurrentGame.scenarios) { if (psm.moduleName == entry.scenarioName) { DarkLog.Debug("Loading existing " + entry.scenarioName + " scenario module"); try { if (psm.moduleRef == null) { DarkLog.Debug("Fixing null scenario module!"); psm.moduleRef = new ScenarioModule(); } psm.moduleRef.Load(scenarioNode); } catch (Exception e) { DarkLog.Debug("Error loading " + entry.scenarioName + " scenario module, Exception: " + e); blockScenarioDataSends = true; } loaded = true; } } if (!loaded) { DarkLog.Debug("Loading new " + entry.scenarioName + " scenario module"); ProtoScenarioModule scenarioModule = new ProtoScenarioModule(scenarioNode); try { HighLogic.CurrentGame.scenarios.Add(scenarioModule); scenarioModule.Load(ScenarioRunner.fetch); } catch (Exception e) { DarkLog.Debug("Error loading " + entry.scenarioName + " scenario module, Exception: " + e); blockScenarioDataSends = true; } } }
public void LoadScenarioDataIntoGame() { while (scenarioQueue.Count > 0) { ScenarioEntry scenarioEntry = scenarioQueue.Dequeue(); if (scenarioEntry.scenarioName == "ContractSystem") { RemoveKerbalRescueMissionsSoTheGameDoesntBugOut(scenarioEntry.scenarioNode); } if (scenarioEntry.scenarioName == "ProgressTracking") { CreateMissingKerbalsInProgressTrackingSoTheGameDoesntBugOut(scenarioEntry.scenarioNode); } ProtoScenarioModule psm = new ProtoScenarioModule(scenarioEntry.scenarioNode); if (psm != null) { if (IsScenarioModuleAllowed(psm.moduleName)) { DarkLog.Debug("Loading " + psm.moduleName + " scenario data"); HighLogic.CurrentGame.scenarios.Add(psm); } else { DarkLog.Debug("Skipping " + psm.moduleName + " scenario data in " + Client.fetch.gameMode + " mode"); } } } }
public void LoadScenarioDataIntoGame() { while (scenarioQueue.Count > 0) { LoadScenarioData(scenarioQueue.Dequeue()); } if (!loadedScience && Client.fetch.gameMode == GameMode.CAREER) { DarkLog.Debug("Creating new science data"); ConfigNode newNode = GetBlankResearchAndDevelopmentNode(); ProtoScenarioModule newModule = new ProtoScenarioModule(newNode); try { HighLogic.CurrentGame.scenarios.Add(newModule); newModule.Load(ScenarioRunner.fetch); } catch { DarkLog.Debug("Error loading new science data!"); blockScenarioDataSends = true; } } }
private void applyScenarioUpdate(KMPScenarioUpdate update) { bool loaded = false; foreach (ProtoScenarioModule proto in HighLogic.CurrentGame.scenarios) { if (proto != null && proto.moduleName == update.name && proto.moduleRef != null && update.getScenarioNode() != null) { Log.Debug("Loading scenario data for existing module: " + update.name); if (update.name == "ResearchAndDevelopment") { ResearchAndDevelopment rd = (ResearchAndDevelopment) proto.moduleRef; Log.Debug("pre-R&D: {0}", rd.Science); } try { proto.moduleRef.Load(update.getScenarioNode()); } catch (Exception e) { KMPClientMain.sendConnectionEndMessage("Error in handling scenario data. Please restart your client. "); Log.Debug(e.ToString()); } if (update.name == "ResearchAndDevelopment") { ResearchAndDevelopment rd = (ResearchAndDevelopment) proto.moduleRef; Log.Debug("post-R&D: {0}", rd.Science); } loaded = true; break; } } if (!loaded) { Log.Debug("Loading new scenario module data: " + update.name); ProtoScenarioModule newScenario = new ProtoScenarioModule(update.getScenarioNode()); //var proto = HighLogic.CurrentGame.AddProtoScenarioModule(newScenario.GetType(), GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION); HighLogic.CurrentGame.scenarios.Add(newScenario); newScenario.Load(ScenarioRunner.fetch); if (update.name == "ScenarioDiscoverableObjects") { ScenarioDiscoverableObjects sdo = (ScenarioDiscoverableObjects) newScenario.moduleRef; sdo.spawnInterval *= (playerStatus.Count()+1); //Throttle spawn rate based on number of players (at connection time) sdo.debugSpawnProbability(); sdoReceived = true; } } clearEditorPartList = true; }
private void handleScenarioUpdate(object obj) { if (obj is KMPScenarioUpdate) { KMPScenarioUpdate update = (KMPScenarioUpdate) obj; bool loaded = false; foreach (ProtoScenarioModule proto in HighLogic.CurrentGame.scenarios) { if (proto != null && proto.moduleName == update.name && proto.moduleRef != null && update.getScenarioNode() != null) { Log.Debug("Loading scenario data for existing module: " + update.name); if (update.name == "ResearchAndDevelopment") { ResearchAndDevelopment rd = (ResearchAndDevelopment) proto.moduleRef; Log.Debug("pre-R&D: {0}", rd.Science); } try { proto.moduleRef.Load(update.getScenarioNode()); } catch (Exception e) { KMPClientMain.sendConnectionEndMessage("Error in handling scenario data. Please restart your client. "); Log.Debug(e.ToString()); } if (update.name == "ResearchAndDevelopment") { ResearchAndDevelopment rd = (ResearchAndDevelopment) proto.moduleRef; Log.Debug("post-R&D: {0}", rd.Science); } loaded = true; break; } } if (!loaded) { Log.Debug("Loading new scenario module data: " + update.name); ProtoScenarioModule newScenario = new ProtoScenarioModule(update.getScenarioNode()); newScenario.Load(ScenarioRunner.fetch); } clearEditorPartList = true; } }