Esempio n. 1
0
 public void LoadProfile(string path)
 {
     this.Data = AIProject.SaveData.SaveData.LoadFile(path);
     if (this.Data == null)
     {
         this.Data = new AIProject.SaveData.SaveData();
     }
     else
     {
         this._bakData = new AIProject.SaveData.SaveData();
         this._bakData.Copy(this.Data);
     }
 }
 public static void GameDataLoadHook(AIProject.SaveData.SaveData saveData, BinaryReader br)
 {
     try
     {
         string marker  = br.ReadString();
         int    version = br.ReadInt32();
         int    length  = br.ReadInt32();
         if (marker == Marker && version == DataVersion && length > 0)
         {
             ReadWorldData(saveData, br);
         }
     }
     catch (EndOfStreamException)
     {
     } //Incomplete/non-existant data
     catch (System.SystemException)
     {
     } //Invalid/unexpected deserialized data
 }
            public static void GameDataSaveHook(AIProject.SaveData.SaveData saveData, BinaryWriter bw)
            {
                Logger.Log(BepInEx.Logging.LogLevel.Debug, "Save Game Data Hook!");

                MainGameSaveWriteEvent(saveData);
                bw.Write(Marker);
                bw.Write(DataVersion);

                // AI's GameSave contains multiple world data.
                // unfortunately it will try to save all the world data so we need to fix it.
                WorldData autoSaveData = saveData.AutoData;

                WriteWorldData(-1, saveData.AutoData, bw);
                foreach (var kv in saveData.WorldList)
                {
                    WriteWorldData(kv.Key, kv.Value, bw);
                    Logger.LogMessage($"Saved world data for {kv.Key}");
                }
            }
Esempio n. 4
0
 public void SaveProfile(string path)
 {
     if (!System.IO.Directory.Exists(AIProject.Definitions.Path.SaveDataDirectory))
     {
         System.IO.Directory.CreateDirectory(AIProject.Definitions.Path.SaveDataDirectory);
     }
     this.Data.SaveFile(path);
     if (this._bakData == null)
     {
         this._bakData = new AIProject.SaveData.SaveData();
         this._bakData.Copy(this.Data);
     }
     else
     {
         path += ".bak";
         this._bakData.SaveFile(path);
         this._bakData.Copy(this.Data);
     }
 }