public static bool PreFLoadGameFromSaveFile(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); bool flag = !Scribe.EnterNode("Κgame"); bool result; if (flag) { Log.Error("Could not find DTMG XML node."); Scribe.ForceStop(); GenScene.GoToMainMenu(); Messages.Message("Game MUST be created with 'Don't Tempt Me!' loaded. Please select a 'Don't Tempt Me!' save game file.", MessageTypeDefOf.RejectInput); result = false; } else { Current.Game = new Game(); Current.Game.LoadGame(); PermadeathModeUtility.CheckUpdatePermadeathModeUniqueNameOnGameLoad(fileName); DeepProfiler.End(); result = false; } return(result); }
public static void RemoveZombieland(string filename) { if (Current.Game == null || Current.Game.Maps == null || Find.World == null) { return; } Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; var zlNamespace = typeof(Tools).Namespace; Current.Game.Maps.Do(map => { // destroy any of our things (even implied like corpse and meat) var allThings = map.listerThings.AllThings.Where(thing => thing.GetType().Namespace == zlNamespace); allThings.Union(map.listerThings.AllThings.Where(thing => thing.def.defName.StartsWith("Zombie_"))); allThings.ToList().Do(thing => thing.Destroy(DestroyMode.Vanish)); // remove any defs in filters of stockpiles map.zoneManager.AllZones.OfType <Zone_Stockpile>().Select(pile => pile?.settings?.filter).ToList() .Do(filter => RemoveZombielandFromFilter(filter)); // remove any defs in work tables map.listerThings.AllThings.OfType <Building_WorkTable>().SelectMany(table => table?.billStack?.Bills ?? new List <Bill>()) .Select(bill => bill?.ingredientFilter).ToList() .Do(filter => RemoveZombielandFromFilter(filter)); // remove any of our map components map.components.RemoveAll(component => component.GetType().Namespace == zlNamespace); // remove any of our hediffs map.mapPawns.AllPawns.Do(pawn => pawn.health.hediffSet.hediffs.RemoveAll(hediff => hediff.GetType().Namespace == zlNamespace)); }); // remove any of our world components Find.World.components.RemoveAll(component => component.GetType().Namespace == zlNamespace); // remove zombie faction var factionManager = Find.World.factionManager; var factions = Traverse.Create(factionManager).Field("allFactions").GetValue <List <Faction> >(); var zombieFaction = factions.First(faction => faction.def == ZombieDefOf.Zombies); factions.Remove(zombieFaction); foreach (var faction in factions) { var relations = Traverse.Create(faction).Field("relations").GetValue <List <FactionRelation> >(); relations.RemoveAll(relation => relation.other == zombieFaction); } // this is how we save a file without our mod reference var runningMods = Traverse.Create(typeof(LoadedModManager)).Field("runningMods").GetValue <List <ModContentPack> >(); var me = runningMods.First(mod => mod.Identifier == ZombielandMod.Identifier); var myIndex = runningMods.IndexOf(me); runningMods.Remove(me); GameDataSaveLoader.SaveGame(filename); runningMods.Insert(myIndex, me); MemoryUtility.ClearAllMapsAndWorld(); GenScene.GoToMainMenu(); }
// Called from Patched Game.LoadGame(). public void LoadGame() { /* * Fill Game components. */ if (Colony == null) { // Return to main menu. Log.Error("Colony is null. - Persistent Worlds"); GenScene.GoToMainMenu(); return; } LongEventHandler.SetCurrentEventText("FilUnderscore.PersistentRimWorlds.Loading.Game".Translate()); Colony.GameData.SetGame(); if (Scribe.mode != LoadSaveMode.LoadingVars) { return; } /* * Load world and maps. */ this.LoadGameWorldAndMaps(); }
public static void RemoveZombieland(string filename) { if (Current.Game == null || Current.Game.Maps == null || Find.World == null) { return; } Find.TickManager.CurTimeSpeed = TimeSpeed.Paused; // note: order is kind of important here Find.BattleLog.Battles.RemoveAll(battle => { battle.Entries.RemoveAll(entry => Traverse.Create(entry).Field("damageDef").GetValue <DamageDef>().IsZombieDef()); return(Traverse.Create(battle).Field("concerns").GetValue <HashSet <Pawn> >().Any(RemoveItem)); }); Find.TaleManager.AllTalesListForReading.RemoveAll(tale => { var singlePawnTale = tale as Tale_SinglePawn; if ((singlePawnTale?.pawnData?.pawn as Zombie) != null) { return(true); } var singlePawnDefTale = tale as Tale_SinglePawnAndDef; if (singlePawnDefTale?.defData?.def.IsZombieDef() ?? false) { return(true); } var doublePawnTale = tale as Tale_DoublePawn; if ((doublePawnTale?.firstPawnData?.pawn as Zombie) != null) { return(true); } if ((doublePawnTale?.secondPawnData?.pawn as Zombie) != null) { return(true); } var doublePawnDefTale = tale as Tale_DoublePawnAndDef; if (doublePawnDefTale?.defData?.def.IsZombieDef() ?? false) { return(true); } return(false); }); Find.World.components.RemoveAll(component => component.IsZombieType()); Current.Game.Maps.Do(CleanMap); Current.Game.Maps.Do(map => PawnsOfType <Pawn>(map).Do(RemovePawnRelatedStuff)); RemoveWorldPawns(); RemoveZombieFaction(); RemoveOutfits(); SaveGameWithoutZombieland(filename); GenScene.GoToMainMenu(); }
/** * CONVERT */ public void Convert(Game game) { this.ConfigurePaths(SaveDir + "/" + game.World.info.name); this.CreateDirectoriesIfNotExistent(); PersistentWorldManager.GetInstance().PersistentWorld.Convert(game); this.SaveWorld(); GenScene.GoToMainMenu(); this.Status = PersistentWorldLoadStatus.Uninitialized; }
private static void <DoMainMenuControls> m__B() { if (GameDataSaveLoader.CurrentGameStateIsValuable) { Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmQuit".Translate(), delegate { GenScene.GoToMainMenu(); }, true, null)); } else { GenScene.GoToMainMenu(); } }
public override void DoWindowContents(Rect inRect) { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperCenter; Widgets.Label(new Rect(0, 0, inRect.width, 40), $"{"MpDesynced".Translate()}\n{text}"); Text.Anchor = TextAnchor.UpperLeft; float buttonWidth = 120 * 4 + 10 * 3; var buttonRect = new Rect((inRect.width - buttonWidth) / 2, 40, buttonWidth, 35); GUI.BeginGroup(buttonRect); float x = 0; if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "MpTryResync".Translate())) { TickPatch.skipToTickUntil = true; TickPatch.skipTo = 0; TickPatch.afterSkip = () => Multiplayer.Client.Send(Packets.Client_WorldReady); Multiplayer.session.desynced = false; ClientJoiningState.ReloadGame(OnMainThread.cachedMapData.Keys.ToList(), false); } x += 120 + 10; if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "Save".Translate())) { Find.WindowStack.Add(new Dialog_SaveReplay()); } x += 120 + 10; if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "MpChatButton".Translate())) { Find.WindowStack.Add(new ChatWindow() { closeOnClickedOutside = true, absorbInputAroundWindow = true }); } x += 120 + 10; if (Widgets.ButtonText(new Rect(x, 0, 120, 35), "Quit".Translate())) { OnMainThread.StopMultiplayer(); GenScene.GoToMainMenu(); } GUI.EndGroup(); }
public static void AskQuitToMainMenu() { if (Multiplayer.LocalServer == null) { GenScene.GoToMainMenu(); return; } Find.WindowStack.Add( Dialog_MessageBox.CreateConfirmation( GetServerCloseConfirmation(), GenScene.GoToMainMenu, true, layer: WindowLayer.Super ) ); }
/// <summary> /// Запускается, когда админ первый раз заходит на сервер, выберет параметры нового мира, и /// первое поселение этого мира стартовало. /// Здесь происходит чтение созданного мира и сохранение его на сервере, само поселение игнорируется. /// </summary> private static void CreatingServerWorld() { Loger.Log("Client CreatingServerWorld()"); //todo Удаление лишнего, добавление того, что нужно в пустом новом мире на сервере //to do //передаем полученное var toServ = new ModelCreateWorld(); toServ.MapSize = GameStarter.SetMapSize; toServ.PlanetCoverage = GameStarter.SetPlanetCoverage; toServ.Seed = GameStarter.SetSeed; toServ.Difficulty = GameStarter.SetDifficulty; /* * toServ.WObjects = Find.World.worldObjects.AllWorldObjects * .Select(wo => new WorldObjectEntry(wo)) * .ToList(); */ //to do var connect = SessionClient.Get; string msg; if (!connect.CreateWorld(toServ)) { msg = "OCity_SessionCC_MsgCreateWorlErr".Translate() + Environment.NewLine + connect.ErrorMessage; } else { msg = "OCity_SessionCC_MsgCreateWorlGood".Translate(); } Find.WindowStack.Add(new Dialog_Input("OCity_SessionCC_MsgCreatingServer".Translate(), msg, true) { PostCloseAction = () => { GenScene.GoToMainMenu(); } }); }
public void EndGameDialogMessage(string msg, Color screenFillColor) { DiaNode diaNode = new DiaNode(msg); DiaOption diaOption2 = new DiaOption("END"); diaOption2.action = delegate { GenScene.GoToMainMenu(); }; diaOption2.resolveTree = true; diaNode.options.Add(diaOption2); Dialog_NodeTree dialog_NodeTree = new Dialog_NodeTree(diaNode, delayInteractivity: true); dialog_NodeTree.screenFillColor = screenFillColor; dialog_NodeTree.silenceAmbientSound = false; dialog_NodeTree.closeOnAccept = false; dialog_NodeTree.closeOnCancel = false; Find.WindowStack.Add(dialog_NodeTree); Find.Archive.Add(new ArchivedDialog(diaNode.text)); }
public void SaveWorld(bool delete = false) { LongEventHandler.QueueLongEvent(delegate { this.SaveColony(); this.ConvertCurrentGameWorldObjects(); this.LoadSaver.SaveWorldData(); this.ConvertToCurrentGameWorldObjects(); if (!delete) { return; } SaveFileUtils.DeleteFile(this.Colony.FileInfo.FullName); GenScene.GoToMainMenu(); }, "FilUnderscore.PersistentRimWorlds.Saving.World", false, null); }
public override void DoWindowContents(Rect inRect) { const float ButtonWidth = 140f; const float ButtonHeight = 40f; Text.Font = GameFont.Small; Text.Anchor = TextAnchor.MiddleCenter; Rect labelRect = inRect; labelRect.yMax -= ButtonHeight; Widgets.Label(labelRect, reason); Text.Anchor = TextAnchor.UpperLeft; Rect buttonRect = new Rect((inRect.width - ButtonWidth) / 2f, inRect.height - ButtonHeight - 10f, ButtonWidth, ButtonHeight); if (Widgets.ButtonText(buttonRect, "QuitToMainMenu".Translate(), true, false, true)) { GenScene.GoToMainMenu(); } }
public static void Disconnected(string msg, Action actionOnDisctonnect = null) { if (actionOnDisctonnect == null) { actionOnDisctonnect = () => GenScene.GoToMainMenu(); } Loger.Log("Client Disconected :( " + msg); GameExit.BeforeExit = null; TimersStop(); SessionClient.Get.Disconnect(); if (msg == null) { GenScene.GoToMainMenu(); } else { Find.WindowStack.Add(new Dialog_Input("OCity_SessionCC_Disconnect".Translate(), msg, true) { PostCloseAction = actionOnDisctonnect }); } }
private static void <DoMainMenuControls> m__10() { GenScene.GoToMainMenu(); }
private static void <EndGameDialogMessage> m__0() { GenScene.GoToMainMenu(); }
public static void Prefix(Rect rect, List <ListableOption> optList) { if (optList.Count > 0 && optList[0].GetType() == typeof(ListableOption)) { if (Current.ProgramState == ProgramState.Entry) { var item = new ListableOption("OCity_LAN_btn".Translate(), delegate { MainMenu.OnMainMenuNetClick(); }, null); optList.Insert(0, item); } else { if (SessionClient.Get.IsLogined) { for (int i = 0; i < optList.Count; i++) { if (optList[i].label == "Save".Translate() || optList[i].label == "LoadGame".Translate() || optList[i].label == "ReviewScenario".Translate() || optList[i].label == "SaveAndQuitToMainMenu".Translate() || optList[i].label == "SaveAndQuitToOS".Translate() || optList[i].label == "ConfirmQuit".Translate() || optList[i].label == "QuitToMainMenu".Translate() || optList[i].label == "QuitToOS".Translate()) { optList.RemoveAt(i--); } } var item = new ListableOption("OCity_MainMenu_Online".Translate(), delegate { Dialog_MainOnlineCity.ShowHide(); }, null); optList.Add(item); if (SessionClientController.Data.AttackModule != null) { item = new ListableOption("OCity_MainMenu_Withdraw".Translate(), delegate { Loger.Log("Client MainMenu VictoryHost"); SessionClientController.Data.AttackModule.VictoryHostToHost = true; }, null); optList.Add(item); } if (SessionClientController.Data.AttackUsModule != null) { item = new ListableOption("OCity_MainMenu_Surrender".Translate(), delegate { Loger.Log("Client MainMenu VictoryAttacker"); SessionClientController.Data.AttackUsModule.ConfirmedVictoryAttacker = true; }, null); optList.Add(item); } item = new ListableOption("QuitToMainMenu".Translate(), delegate { if (GameExit.BeforeExit != null) { GameExit.BeforeExit(); } GenScene.GoToMainMenu(); }, null); optList.Add(item); item = new ListableOption("QuitToOS".Translate(), delegate { if (GameExit.BeforeExit != null) { GameExit.BeforeExit(); } Root.Shutdown(); }, null); optList.Add(item); } } } if (Inited) { return; } Inited = true; SessionClientController.Init(); }