コード例 #1
0
        private static void Postfix()
        {
            if (!Main.Enabled || !Main.DoBackup)
            {
                return;
            }

            SaveManager.Backup(SaveManager.AfterSaveBackup);
            Main.DoBackup = false;
        }
コード例 #2
0
ファイル: Patch.cs プロジェクト: zhishu233/Taiwu_mods
        /// <summary>
        /// 替换原本的SaveDateFile.EnsureFiles
        /// </summary>
        /// <returns></returns>
        private static void EnsureFiles()
        {
            string[] fileNames = new string[9]
            {
                SaveDateFile.instance.GameSettingName,
                SaveDateFile.instance.WorldDateName2,
                SaveDateFile.instance.WorldDateName4,
                SaveDateFile.instance.saveDateName,
                SaveDateFile.instance.homeBuildingName,
                SaveDateFile.instance.WorldDateName3,
                SaveDateFile.instance.PlaceResourceName,
                SaveDateFile.instance.actorLifeName,
                SaveDateFile.instance.legendBookName
            };
            string path = SaveManager.SavePath;
            int    num;

            for (int i = 0; i < fileNames.Length; i = num)
            {
                string tmpFile = $"{path}{fileNames[i]}{SaveDateFile.instance.saveVersionName}~";
                string dstFile = $"{path}{fileNames[i]}{SaveDateFile.instance.saveVersionName}";
                if (!File.Exists(tmpFile))
                {
                    Debug.Log("存档异常");
                    break;
                }
                if (File.Exists(dstFile))
                {
                    File.Replace(tmpFile, dstFile, null);
                }
                else
                {
                    File.Move(tmpFile, dstFile);
                }
                num = i + 1;
            }
            Debug.Log("完成保存存档操作,开始执行随档备份...");

            SaveManager.Backup(SaveManager.AfterSaveBackup);
        }