public static SinglePlayerCampaign Load(XElement element) { SinglePlayerCampaign campaign = new SinglePlayerCampaign(GameModePreset.list.Find(gm => gm.Name == "Single Player"), null); foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "crew": GameMain.GameSession.CrewManager = new CrewManager(subElement); break; case "map": campaign.map = Map.LoadNew(subElement); break; } } campaign.Money = element.GetAttributeInt("money", 0); //backwards compatibility with older save files if (campaign.map == null) { string mapSeed = element.GetAttributeString("mapseed", "a"); campaign.GenerateMap(mapSeed); campaign.map.SetLocation(element.GetAttributeInt("currentlocation", 0)); } campaign.savedOnStart = true; return(campaign); }
/*private IEnumerable<object> EndCinematic(RoundEndCinematic cinematic) * { * while (cinematic.Running) * { * if (Submarine.MainSub == null) yield return CoroutineStatus.Success; * * yield return CoroutineStatus.Running; * } * * if (Submarine.MainSub != null) End(""); * * yield return CoroutineStatus.Success; * }*/ public static SinglePlayerCampaign Load(XElement element) { SinglePlayerCampaign campaign = new SinglePlayerCampaign(GameModePreset.List.Find(gm => gm.Identifier == "singleplayercampaign"), null); foreach (XElement subElement in element.Elements()) { switch (subElement.Name.ToString().ToLowerInvariant()) { case "crew": GameMain.GameSession.CrewManager = new CrewManager(subElement, true); break; case "map": campaign.map = Map.LoadNew(subElement); break; case "contextualtutorial": campaign.ContextualTutorial.Initialize(); // Initialize when saved element found campaign.ContextualTutorial.LoadPartiallyComplete(subElement); break; } } campaign.Money = element.GetAttributeInt("money", 0); campaign.CheatsEnabled = element.GetAttributeBool("cheatsenabled", false); if (campaign.CheatsEnabled) { DebugConsole.CheatsEnabled = true; if (GameMain.Config.UseSteam && !SteamAchievementManager.CheatsEnabled) { SteamAchievementManager.CheatsEnabled = true; new GUIMessageBox("Cheats enabled", "Cheat commands have been enabled on the campaign. You will not receive Steam Achievements until you restart the game."); } } //backwards compatibility with older save files if (campaign.map == null) { string mapSeed = element.GetAttributeString("mapseed", "a"); campaign.GenerateMap(mapSeed); campaign.map.SetLocation(element.GetAttributeInt("currentlocation", 0)); } campaign.savedOnStart = true; return(campaign); }