示例#1
0
        public void WriteData(GameDataSnapshot gameData)
        {
            string sectionId = info.sections.Count.ToString("D3");

            using var zip = ZipFile;

            foreach (var(mapId, mapData) in gameData.mapData)
            {
                zip.AddEntry($"maps/{sectionId}_{mapId}_save", mapData);
            }

            foreach (var(mapId, mapCmdData) in gameData.mapCmds)
            {
                if (mapId >= 0)
                {
                    zip.AddEntry($"maps/{sectionId}_{mapId}_cmds", SerializeCmds(mapCmdData));
                }
            }

            if (gameData.mapCmds.TryGetValue(ScheduledCommand.Global, out var worldCmds))
            {
                zip.AddEntry($"world/{sectionId}_cmds", SerializeCmds(worldCmds));
            }

            zip.AddEntry($"world/{sectionId}_save", gameData.gameData);
            info.sections.Add(new ReplaySection(gameData.cachedAtTime, TickPatch.Timer));

            zip.UpdateEntry("info", DirectXmlSaver.XElementFromObject(info, typeof(ReplayInfo)).ToString());
            zip.Save();
        }
示例#2
0
 public void WriteInfo()
 {
     using (var zip = ZipFile)
     {
         zip.UpdateEntry("info", DirectXmlSaver.XElementFromObject(info, typeof(ReplayInfo)).ToString());
         zip.Save();
     }
 }
示例#3
0
 public static void Save()
 {
     try
     {
         var xDocument = new XDocument();
         var content   = DirectXmlSaver.XElementFromObject(data, typeof(BadPeoplePerfsData));
         xDocument.Add(content);
         xDocument.Save(prefsFilePath);
     }
     catch (Exception ex)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(prefsFilePath, ex.ToString()));
         Log.Error("Exception saving prefs: " + ex);
     }
 }
 public static void Save()
 {
     try
     {
         XDocument xDocument = new XDocument();
         XElement  content   = DirectXmlSaver.XElementFromObject(data, typeof(ConceptKnowledge));
         xDocument.Add(content);
         xDocument.Save(GenFilePaths.ConceptKnowledgeFilePath);
     }
     catch (Exception ex)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(GenFilePaths.ConceptKnowledgeFilePath, ex.ToString()));
         Log.Error("Exception saving knowledge database: " + ex);
     }
 }
示例#5
0
 public static void Save()
 {
     Other.Tutorials.UpdateTutorialFlags();
     try
     {
         var xDocument = new XDocument();
         var content   = DirectXmlSaver.XElementFromObject(data, typeof(PrisonLaborPrefsData));
         xDocument.Add(content);
         xDocument.Save(prefsFilePath);
     }
     catch (Exception ex)
     {
         GenUI.ErrorDialog("ProblemSavingFile".Translate(prefsFilePath, ex.ToString()));
         Log.Error("Exception saving prefs: " + ex);
     }
 }