public static string GeneratePermadeathSaveName() { string text = NameGenerator.GenerateName(Faction.OfPlayer.def.factionNameMaker, null, false, null, null); text = GenFile.SanitizedFileName(text); return(PermadeathModeUtility.NewPermadeathSaveNameWithAppendedNumberIfNecessary(text, null)); }
public static void LoadGameFromSaveFileNow(string fileName) { string str = (from mod in LoadedModManager.RunningMods select mod.ToString()).ToCommaList(); 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(); try { ScribeMetaHeaderUtility.LoadGameDataHeader(ScribeMetaHeaderUtility.ScribeHeaderMode.Map, logVersionConflictWarning: true); if (!Scribe.EnterNode("game")) { Log.Error("Could not find game XML node."); Scribe.ForceStop(); return; } Current.Game = new Game(); Current.Game.LoadGame(); } catch (Exception) { Scribe.ForceStop(); throw; } PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); }
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(); } }
private static string NewPermadeathSaveNameWithAppendedNumberIfNecessary(string name, string acceptedNameEvenIfTaken = null) { int num = 0; string text; do { num++; text = name; if (num != 1) { text += num; } text = PermadeathModeUtility.AppendedPermadeathModeSuffix(text); }while (SaveGameFilesUtility.SavedGameNamedExists(text) && text != acceptedNameEvenIfTaken); return(text); }
public static string GeneratePermadeathSaveName() { string text = NameGenerator.GenerateName(Faction.OfPlayer.def.factionNameMakerPlayer, null, false, null); int num = 0; string text2; do { num++; text2 = text; if (num != 1) { text2 += num; } text2 = PermadeathModeUtility.AppendPermadeathModeSuffix(text2); }while (SaveGameFilesUtility.SavedGameNamedExists(text2)); return(text2); }
public static string GeneratePermadeathSaveName() { string text = NameGenerator.GenerateName(Faction.OfPlayer.def.factionNameMakerPlayer, (Predicate <string>)null, false, (string)null); int num = 0; string text2; while (true) { num++; text2 = text; if (num != 1) { text2 += num; } text2 = PermadeathModeUtility.AppendPermadeathModeSuffix(text2); if (!SaveGameFilesUtility.SavedGameNamedExists(text2)) { break; } } return(text2); }
public static string GeneratePermadeathSaveNameBasedOnPlayerInput(string factionName, string acceptedNameEvenIfTaken = null) { string name = GenFile.SanitizedFileName(factionName); return(PermadeathModeUtility.NewPermadeathSaveNameWithAppendedNumberIfNecessary(name, acceptedNameEvenIfTaken)); }
public void InitNewGame() { string str = (from mod in LoadedModManager.RunningMods select mod.ToString()).ToCommaList(false); Log.Message("Initializing new game with mods " + str, false); if (this.maps.Any <Map>()) { Log.Error("Called InitNewGame() but there already is a map. There should be 0 maps...", false); return; } if (this.initData == null) { Log.Error("Called InitNewGame() but init data is null. Create it first.", false); return; } MemoryUtility.UnloadUnusedUnityAssets(); DeepProfiler.Start("InitNewGame"); try { Current.ProgramState = ProgramState.MapInitializing; IntVec3 intVec = new IntVec3(this.initData.mapSize, 1, this.initData.mapSize); Settlement settlement = null; List <Settlement> settlements = Find.WorldObjects.Settlements; for (int i = 0; i < settlements.Count; i++) { if (settlements[i].Faction == Faction.OfPlayer) { settlement = settlements[i]; break; } } if (settlement == null) { Log.Error("Could not generate starting map because there is no any player faction base.", false); } this.tickManager.gameStartAbsTick = GenTicks.ConfiguredTicksAbsAtGameStart; Map currentMap = MapGenerator.GenerateMap(intVec, settlement, settlement.MapGeneratorDef, settlement.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.CurrentMap = currentMap; Find.CameraDriver.JumpToCurrentMapLoc(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 (ResearchProjectTagDef current in Faction.OfPlayer.def.startingResearchTags) { foreach (ResearchProjectDef current2 in DefDatabase <ResearchProjectDef> .AllDefs) { if (current2.HasTag(current)) { this.researchManager.FinishProject(current2, false, null); } } } } GameComponentUtility.StartedNewGame(); this.initData = null; } finally { DeepProfiler.End(); } }
public void InitNewGame() { string str = LoadedModManager.RunningMods.Select((ModContentPack mod) => mod.PackageIdPlayerFacing).ToLineList(" - "); Log.Message("Initializing new game with mods:\n" + str); if (maps.Any()) { Log.Error("Called InitNewGame() but there already is a map. There should be 0 maps..."); return; } if (initData == null) { Log.Error("Called InitNewGame() but init data is null. Create it first."); return; } MemoryUtility.UnloadUnusedUnityAssets(); DeepProfiler.Start("InitNewGame"); try { //InitMap Current.ProgramState = ProgramState.MapInitializing; IntVec3 intVec = new IntVec3(initData.mapSize, 1, initData.mapSize); Settlement settlement = null; List <Settlement> settlements = Find.WorldObjects.Settlements; for (int i = 0; i < settlements.Count; i++) { if (settlements[i].Faction == Faction.OfPlayer) { settlement = settlements[i]; break; } } if (settlement == null) { Log.Error("Could not generate starting map because there is no any player faction base."); } tickManager.gameStartAbsTick = GenTicks.ConfiguredTicksAbsAtGameStart; //-------------- //Map currentMap=Map //Map currentMap = MapGenerator.GenerateMap(intVec, settlement, settlement.MapGeneratorDef, settlement.ExtraGenStepDefs); //Map currentMap=MapGenerator.GenerateMap(intVec,settlement,settlement.MapGeneratorDef,settlement.ExtraGenStepDefs) Map currentMap = MapGenerator.GenerateMap(intVec, settlement, settlement.MapGeneratorDef, settlement.ExtraGenStepDefs); worldInt.info.initialMapSize = intVec; if (initData.permadeath) { info.permadeathMode = true; info.permadeathModeUniqueName = PermadeathModeUtility.GeneratePermadeathSaveName(); } PawnUtility.GiveAllStartingPlayerPawnsThought(ThoughtDefOf.NewColonyOptimism); FinalizeInit(); Current.Game.CurrentMap = currentMap; Find.CameraDriver.JumpToCurrentMapLoc(MapGenerator.PlayerStartSpot); Find.CameraDriver.ResetSize(); if (Prefs.PauseOnLoad && initData.startedFromEntry) { LongEventHandler.ExecuteWhenFinished(delegate { tickManager.DoSingleTick(); tickManager.CurTimeSpeed = TimeSpeed.Paused; }); } //--------------end Find.Scenario.PostGameStart(); if (Faction.OfPlayer.def.startingResearchTags != null) { foreach (ResearchProjectTagDef startingResearchTag in Faction.OfPlayer.def.startingResearchTags) { foreach (ResearchProjectDef allDef in DefDatabase <ResearchProjectDef> .AllDefs) { if (allDef.HasTag(startingResearchTag)) { researchManager.FinishProject(allDef); } } } } if (Faction.OfPlayer.def.startingTechprintsResearchTags != null) { foreach (ResearchProjectTagDef startingTechprintsResearchTag in Faction.OfPlayer.def.startingTechprintsResearchTags) { foreach (ResearchProjectDef allDef2 in DefDatabase <ResearchProjectDef> .AllDefs) { if (allDef2.HasTag(startingTechprintsResearchTag)) { int techprints = researchManager.GetTechprints(allDef2); if (techprints < allDef2.techprintCount) { researchManager.AddTechprints(allDef2, allDef2.techprintCount - techprints); } } } } } GameComponentUtility.StartedNewGame(); initData = null; } finally { DeepProfiler.End(); } }
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()) { Log.Error("Called InitNewGame() but there already is a map. There should be 0 maps..."); } else if (this.initData == null) { Log.Error("Called InitNewGame() but init data is null. Create it first."); } else { 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; int num = 0; while (num < factionBases.Count) { if (factionBases[num].Faction != Faction.OfPlayer) { num++; continue; } factionBase = factionBases[num]; 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 startingResearchTag in Faction.OfPlayer.def.startingResearchTags) { foreach (ResearchProjectDef allDef in DefDatabase <ResearchProjectDef> .AllDefs) { if (allDef.HasTag(startingResearchTag)) { this.researchManager.InstantFinish(allDef, false); } } } } GameComponentUtility.StartedNewGame(); this.initData = null; } finally { DeepProfiler.End(); } } }