public static void LoadGameFromSaveFile(string fileName) { string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods select mod.ToString(), true); Log.Message("Loading game from file " + fileName + " with mods " + str); DeepProfiler.Start("Loading game from file " + fileName); Current.Game = new Game(); DeepProfiler.Start("InitLoading (read file)"); Scribe.loader.InitLoading(GenFilePaths.FilePathForSavedGame(fileName)); DeepProfiler.End(); ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, true); if (Scribe.EnterNode("game")) { Current.Game = new Game(); Current.Game.LoadGame(); PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); } else { Log.Error("Could not find game XML node."); Scribe.ForceStop(); } }
public override string ToString() { string text = GenText.ToCommaList(from r in this.regions where r != null select r.id.ToString(), true); string text2 = "span=" + this.span.ToString() + " hash=" + this.UniqueHashCode(); return("(" + text2 + ", regions=" + text + ")"); }
public override string ToString() { string text = GenText.ToCommaList(from r in this.regions where r != null select r.id.ToString(), true); string text2 = string.Concat(new object[] { "span=", this.span.ToString(), " hash=", this.UniqueHashCode() }); return(string.Concat(new string[] { "(", text2, ", regions=", text, ")" })); }
public static bool LoadedModsMatchesActiveMods(out string loadedModsSummary, out string runningModsSummary) { loadedModsSummary = null; runningModsSummary = null; List <string> list = (from mod in LoadedModManager.RunningMods select mod.Identifier).ToList(); if (ScribeMetaHeaderUtility.ModListsMatch(ScribeMetaHeaderUtility.loadedModIdsList, list)) { return(true); } if (ScribeMetaHeaderUtility.loadedModNamesList == null) { loadedModsSummary = "None".Translate(); } else { loadedModsSummary = GenText.ToCommaList(ScribeMetaHeaderUtility.loadedModNamesList, true); } runningModsSummary = GenText.ToCommaList(from id in list select ModLister.GetModWithIdentifier(id).Name, true); return(false); }
public static IEnumerable <StatDrawEntry> SpecialDisplayStats(HediffStage stage, Hediff instance) { if (instance != null && instance.Bleeding) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "BleedingRate".Translate(), instance.BleedRate.ToStringPercent() + "/" + "LetterDay".Translate(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } float painOffsetToDisplay = 0f; if (instance != null) { painOffsetToDisplay = instance.PainOffset; } else if (stage != null) { painOffsetToDisplay = stage.painOffset; } if (painOffsetToDisplay != 0.0) { if (painOffsetToDisplay > 0.0 && painOffsetToDisplay < 0.0099999997764825821) { painOffsetToDisplay = 0.01f; } if (painOffsetToDisplay < 0.0 && painOffsetToDisplay > -0.0099999997764825821) { painOffsetToDisplay = -0.01f; } yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Pain".Translate(), ((float)(painOffsetToDisplay * 100.0)).ToString("+###0;-###0") + "%", 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } float painFactorToDisplay = 1f; if (instance != null) { painFactorToDisplay = instance.PainFactor; } else if (stage != null) { painFactorToDisplay = stage.painFactor; } if (painFactorToDisplay != 1.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Pain".Translate(), "x" + painFactorToDisplay.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (stage != null && stage.partEfficiencyOffset != 0.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "PartEfficiency".Translate(), stage.partEfficiencyOffset.ToStringByStyle(ToStringStyle.PercentZero, ToStringNumberSense.Offset), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } List <PawnCapacityModifier> capModsToDisplay = null; if (instance != null) { capModsToDisplay = instance.CapMods; } else if (stage != null) { capModsToDisplay = stage.capMods; } if (capModsToDisplay != null) { for (int j = 0; j < capModsToDisplay.Count; j++) { if (capModsToDisplay[j].offset != 0.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, capModsToDisplay[j].capacity.GetLabelFor(true, true).CapitalizeFirst(), ((float)(capModsToDisplay[j].offset * 100.0)).ToString("+#;-#") + "%", 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (capModsToDisplay[j].postFactor != 1.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, capModsToDisplay[j].capacity.GetLabelFor(true, true).CapitalizeFirst(), "x" + capModsToDisplay[j].postFactor.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (capModsToDisplay[j].SetMaxDefined) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, capModsToDisplay[j].capacity.GetLabelFor(true, true).CapitalizeFirst(), "max".Translate() + " " + capModsToDisplay[j].setMax.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } } } if (stage == null) { yield break; } if (!stage.AffectsMemory && !stage.AffectsSocialInteractions) { if (stage.hungerRateFactor != 1.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "HungerRate".Translate(), "x" + stage.hungerRateFactor.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (stage.hungerRateFactorOffset != 0.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "HungerRate".Translate(), stage.hungerRateFactorOffset.ToStringSign() + stage.hungerRateFactorOffset.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (stage.restFallFactor != 1.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Tiredness".Translate(), "x" + stage.restFallFactor.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (stage.restFallFactorOffset != 0.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Tiredness".Translate(), stage.restFallFactorOffset.ToStringSign() + stage.restFallFactorOffset.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (stage.makeImmuneTo != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "PreventsInfection".Translate(), GenText.ToCommaList(from im in stage.makeImmuneTo select im.label, false).CapitalizeFirst(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (stage.statOffsets != null) { int i = 0; if (i < stage.statOffsets.Count) { StatModifier sm = stage.statOffsets[i]; yield return(new StatDrawEntry(StatCategoryDefOf.Basics, sm.stat.LabelCap, sm.ValueToStringAsOffset, 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } } yield break; } StringBuilder affectsSb = new StringBuilder(); if (stage.AffectsMemory) { if (affectsSb.Length != 0) { affectsSb.Append(", "); } affectsSb.Append("MemoryLower".Translate()); } if (stage.AffectsSocialInteractions) { if (affectsSb.Length != 0) { affectsSb.Append(", "); } affectsSb.Append("SocialInteractionsLower".Translate()); } yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Affects".Translate(), affectsSb.ToString(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; }
public void InitNewGame() { string str = GenText.ToCommaList(from mod in LoadedModManager.RunningMods select mod.ToString(), true); Log.Message("Initializing new game with mods " + str); if (this.maps.Any <Map>()) { Log.Error("Called InitNewGame() but there already is a map. There should be 0 maps..."); return; } if (this.initData == null) { Log.Error("Called InitNewGame() but init data is null. Create it first."); return; } MemoryUtility.UnloadUnusedUnityAssets(); DeepProfiler.Start("InitNewGame"); try { Current.ProgramState = ProgramState.MapInitializing; IntVec3 intVec = new IntVec3(this.initData.mapSize, 1, this.initData.mapSize); FactionBase factionBase = null; List <FactionBase> factionBases = Find.WorldObjects.FactionBases; for (int i = 0; i < factionBases.Count; i++) { if (factionBases[i].Faction == Faction.OfPlayer) { factionBase = factionBases[i]; break; } } if (factionBase == null) { Log.Error("Could not generate starting map because there is no any player faction base."); } this.tickManager.gameStartAbsTick = GenTicks.ConfiguredTicksAbsAtGameStart; Map visibleMap = MapGenerator.GenerateMap(intVec, factionBase, factionBase.MapGeneratorDef, factionBase.ExtraGenStepDefs, null); this.worldInt.info.initialMapSize = intVec; if (this.initData.permadeath) { this.info.permadeathMode = true; this.info.permadeathModeUniqueName = PermadeathModeUtility.GeneratePermadeathSaveName(); } PawnUtility.GiveAllStartingPlayerPawnsThought(ThoughtDefOf.NewColonyOptimism); this.FinalizeInit(); Current.Game.VisibleMap = visibleMap; Find.CameraDriver.JumpToVisibleMapLoc(MapGenerator.PlayerStartSpot); Find.CameraDriver.ResetSize(); if (Prefs.PauseOnLoad && this.initData.startedFromEntry) { LongEventHandler.ExecuteWhenFinished(delegate { this.tickManager.DoSingleTick(); this.tickManager.CurTimeSpeed = TimeSpeed.Paused; }); } Find.Scenario.PostGameStart(); if (Faction.OfPlayer.def.startingResearchTags != null) { foreach (string current in Faction.OfPlayer.def.startingResearchTags) { foreach (ResearchProjectDef current2 in DefDatabase <ResearchProjectDef> .AllDefs) { if (current2.HasTag(current)) { this.researchManager.InstantFinish(current2, false); } } } } GameComponentUtility.StartedNewGame(); this.initData = null; } finally { DeepProfiler.End(); } }
public override IEnumerable <StatDrawEntry> SpecialDisplayStats() { if (this.workSkill != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Skill".Translate(), this.workSkill.LabelCap, 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (this.ingredients != null && this.ingredients.Count > 0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Ingredients".Translate(), GenText.ToCommaList(from ic in this.ingredients select ic.Summary, true), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (this.skillRequirements != null && this.skillRequirements.Count > 0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "SkillRequirements".Translate(), GenText.ToCommaList(from sr in this.skillRequirements select sr.Summary, true), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (this.products != null && this.products.Count > 0) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "Products".Translate(), GenText.ToCommaList(from pr in this.products select pr.Summary, true), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (this.workSpeedStat != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "WorkSpeedStat".Translate(), this.workSpeedStat.LabelCap, 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (this.efficiencyStat != null) { yield return(new StatDrawEntry(StatCategoryDefOf.Basics, "EfficiencyStat".Translate(), this.efficiencyStat.LabelCap, 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } if (!this.IsSurgery) { yield break; } if (this.surgerySuccessChanceFactor >= 99999.0) { yield return(new StatDrawEntry(StatCategoryDefOf.Surgery, "SurgerySuccessChanceFactor".Translate(), "Always", 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; } yield return(new StatDrawEntry(StatCategoryDefOf.Surgery, "SurgerySuccessChanceFactor".Translate(), this.surgerySuccessChanceFactor.ToStringPercent(), 0, string.Empty)); /*Error: Unable to find new state assignment for yield return*/; }
public override string ToString() { return(string.Format("{0}({1})", base.ToString(), GenText.ToCommaList(this.mods, false))); }
public static bool TryCreateDialogsForVersionMismatchWarnings(Action confirmedAction) { string text = null; string text2 = null; if (!BackCompatibility.IsSaveCompatibleWith(ScribeMetaHeaderUtility.loadedGameVersion) && !ScribeMetaHeaderUtility.VersionsMatch()) { text2 = "VersionMismatch".Translate(); string text3 = (!ScribeMetaHeaderUtility.loadedGameVersion.NullOrEmpty()) ? ScribeMetaHeaderUtility.loadedGameVersion : ("(" + "UnknownLower".Translate() + ")"); text = ((ScribeMetaHeaderUtility.lastMode != ScribeHeaderMode.Map) ? ((ScribeMetaHeaderUtility.lastMode != ScribeHeaderMode.World) ? "FileIncompatibleWarning".Translate(text3, VersionControl.CurrentVersionString) : "WorldFileVersionMismatch".Translate(text3, VersionControl.CurrentVersionString)) : "SaveGameIncompatibleWarningText".Translate(text3, VersionControl.CurrentVersionString)); } bool flag = false; string text4 = default(string); string text5 = default(string); if (!ScribeMetaHeaderUtility.LoadedModsMatchesActiveMods(out text4, out text5)) { flag = true; string text6 = "ModsMismatchWarningText".Translate(text4, text5); text = ((text != null) ? (text + "\n\n" + text6) : text6); if (text2 == null) { text2 = "ModsMismatchWarningTitle".Translate(); } } if (text != null) { string text7 = text; string title = text2; Dialog_MessageBox dialog = Dialog_MessageBox.CreateConfirmation(text7, confirmedAction, false, title); dialog.buttonAText = "LoadAnyway".Translate(); if (flag) { dialog.buttonCText = "ChangeLoadedMods".Translate(); dialog.buttonCAction = delegate { int num = ModLister.InstalledModsListHash(false); ModsConfig.SetActiveToList(ScribeMetaHeaderUtility.loadedModIdsList); ModsConfig.Save(); if (num == ModLister.InstalledModsListHash(false)) { IEnumerable <string> items = from id in Enumerable.Range(0, ScribeMetaHeaderUtility.loadedModIdsList.Count) where ModLister.GetModWithIdentifier(ScribeMetaHeaderUtility.loadedModIdsList[id]) == null select ScribeMetaHeaderUtility.loadedModNamesList[id]; Messages.Message(string.Format("{0}: {1}", "MissingMods".Translate(), GenText.ToCommaList(items, true)), MessageTypeDefOf.RejectInput); dialog.buttonCClose = false; } else { ModsConfig.RestartFromChangedMods(); } }; } Find.WindowStack.Add(dialog); return(true); } return(false); }