public void CopyFromStash2(string fileName)
        {
            // saving...
            // copy from areas folder to SaveGame

            try
            {
                var    areasFolder = AreaDataStash2.GetAreasFolder();
                string fileToCopy  = Path.Combine(areasFolder, fileName);

                // this check is missing in the FolderSaver.CopyFromStash
                if (File.Exists(fileToCopy))
                {
                    CopyFromStashBase(fileName);
                }
                else
                {
                    //BattleLogHelper.LogDebug($"doesnt exist: {fileToCopy}");
                }
            }
            catch (Exception ex)
            {
                BattleLogHelper.LogDebug($"err {ex.ToString()}");
            }
        }
        public void PrepareSave2(SaveInfo save)
        {
            PrepareSaveBase(save);

            // !string.IsNullOrEmpty(FolderName);
            // !save.IsActuallySaved

            try
            {
                if (save.FolderName.EndsWith(".zks") || save.Saver == null ||
                    save.Saver.GetType() != typeof(FolderSaver2))
                {
                    // set folderName, (remove file extension)
                    save.FolderName = save.FolderName.Replace(".zks", "");

                    //save.Saver = new FolderSaver(save.FolderName);
                    save.Saver = ((ISaver) new FolderSaver2(save.FolderName));

                    if (save.Type == SaveInfo.SaveType.Quick)
                    {
                        // set name of quicksave to folder name
                        // save.Name = Path.GetFileName(save.FolderName);
                    }
                }
            }
            catch (Exception ex)
            {
                BattleLogHelper.LogDebug($"err {ex.ToString()}");
            }
        }
        public void CopyToStash(string fileName)
        {
            // m_FolderName: ...AppData\LocalLow\Owlcat Games\Pathfinder Kingmaker\Saved Games
            // areas folder: ...AppData/Local/Temp/Owlcat Games/Pathfinder Kingmaker\Areas

            var areasFolder = AreaDataStash2.GetAreasFolder();

            var saveGameFile = Path.Combine(m_FolderName, fileName);
            var destination  = Path.Combine(areasFolder, fileName);

            var fi1 = new FileInfo(saveGameFile);
            var fi2 = new FileInfo(destination);

            if (FileHelper2.FileHasChanges(fi1, fi2))
            {
                File.Delete(destination);

                BattleLogHelper.LogDebug($"has changes, copy to {destination}");
                CopyToStashBase(fileName);
            }
            else
            {
                // BattleLogHelper.LogDebug($"no changes");
            }
        }
        private void RemoveAllFilesNotInSaveGame()
        {
            if (m_SaveInfo?.Saver == null)
            {
                return;
            }

            var allFiles        = m_SaveInfo.Saver.GetAllFiles();
            var saveContentsDic = new HashSet <string>(allFiles);

            var areasFolder = AreaDataStash2.GetAreasFolder();

            Directory.CreateDirectory(areasFolder); // create if not exists

            // remove all files not in save
            foreach (var item in new DirectoryInfo(areasFolder).GetFiles())
            {
                var fileNameInArea = item.Name;

                if (!saveContentsDic.Contains(fileNameInArea))
                {
                    File.Delete(item.FullName);
                    BattleLogHelper.LogDebug($"not in save, delete {item.FullName}");
                }
            }
        }
Exemplo n.º 5
0
 public void SkillCast(Actor caster, Skill skill)
 {
     foreach (var target in GetTarget(caster, skill))
     {
         var skillResult = skill.OnCast(caster.CharacterInfo, target.CharacterInfo, _rand);
         Messenger.Broadcast(MsgConst.BATTLE_LOG, BattleLogHelper.GenerateBattleLog(caster, target, skill, skillResult));
         Messenger.Broadcast(MsgConst.ACTOR_DAMAGE, target.CharacterInfo.ID, skillResult);
         Messenger.Broadcast(MsgConst.ACTOR_EFFECT, target.CharacterInfo.ID, "hit_effect_01");
         SkillHit(target, skillResult);
         if (!IsRunning)
         {
             break;
         }
     }
 }
Exemplo n.º 6
0
        public static void ClearAll2()
        {
            var areasFolder = GetAreasFolder();

            BattleLogHelper.LogDebug($"try to delete : {areasFolder}");

            if (Directory.Exists(areasFolder))
            {
                // remove this "security check" if you dont need it
                if (areasFolder.Contains(@"AppData/Local/Temp/Owlcat Games/Pathfinder Kingmaker\Areas"))
                {
                    Directory.Delete(areasFolder, true);
                    BattleLogHelper.LogDebug($"deleted : {areasFolder}");
                }
            }

            Directory.CreateDirectory(areasFolder);
        }
        public ThreadedGameLoader2(SaveInfo m_SaveInfo, bool isSmokeTest)
        {
            this.m_SaveInfo    = m_SaveInfo;
            this.m_IsSmokeTest = isSmokeTest;

            try
            {
                // Usually AreaDataStash.ClearAll (clear area folder) is called before this ctor is invoked

                if (m_SaveInfo.Saver.GetType() == typeof(ZipSaver2))
                {
                    AreaDataStash2.ClearAll2(); // keep the old functionality
                }
                else
                {
                    RemoveAllFilesNotInSaveGame();
                }
            }
            catch (Exception ex)
            {
                BattleLogHelper.LogDebug($"ThreadedGameLoader .ctor {ex.ToString()}");
            }
        }