Exemplo n.º 1
0
        public static void ReplaceCurrentChapter(string chapterName)
        {
            string chapterDirectory = GetChapterDirectory(chapterName);

            ClearCurrentSave();
            DirectoryExtensions.CopyAll(chapterDirectory, CurrentSavePath);
        }
Exemplo n.º 2
0
        public static void Save(MyMwcObjectBuilder_Checkpoint checkpoint, MyMwcObjectBuilder_Sector sector, MyMwcSectorIdentifier sectorIdentifier, bool createChapter = false)
        {
            if (sector == null) // Nothing to save, saving only checkpoint
            {
                return;
            }

            string sectorPath     = GetSectorPath(sectorIdentifier);
            string storeDirectory = Path.GetDirectoryName(sectorPath);

            // Store current sector
            SaveData(sector, sectorPath);


            // Store checkpoint
            if (checkpoint != null)
            {
                string checkpointPath = Path.Combine(storeDirectory, "Checkpoint.mwc");

                var oldValue = checkpoint.SectorObjectBuilder;
                checkpoint.SectorObjectBuilder = null;

                SaveData(checkpoint, checkpointPath);

                checkpoint.SectorObjectBuilder = oldValue;
            }

            if (createChapter)
            {
                var chapterDirectory = GetChapterDirectory(GetChapterName(checkpoint));
                if (Directory.Exists(chapterDirectory))
                {
                    Directory.Delete(chapterDirectory, true);
                }
                DirectoryExtensions.CopyAll(storeDirectory, chapterDirectory);
            }

            Log("update", sectorIdentifier, sector.Version);
        }