Esempio n. 1
0
        public static IEnumerator SaveAllChunks()
        {
            /*if (!Engine.SaveVoxelData) {
             *  Debug.LogWarning ("Uniblocks: Saving is disabled. You can enable it in the Engine Settings.");
             *  yield break;
             * }*/
            while (ChunkDataFiles.SavingChunks)
            {
                yield return(new WaitForEndOfFrame());
            }
            ChunkDataFiles.SavingChunks = true;

            // for each chunk object, save data to memory
            int          count        = 0;
            List <Chunk> chunksToSave = new List <Chunk>(ChunkManager.Chunks.Values);


            foreach (Chunk chunk in chunksToSave)
            {
                chunk.gameObject.GetComponent <ChunkDataFiles>().SaveData();
                count++;
                if (count > Engine.MaxChunkSaves)
                {
                    yield return(new WaitForEndOfFrame());

                    count = 0;
                }
            }

            // write data to disk
            ChunkDataFiles.WriteLoadedChunks();
            ChunkDataFiles.SavingChunks = false;

            Debug.Log("Uniblocks: World saved successfully.");
        }
Esempio n. 2
0
        public static void SaveAllChunksInstant()
        { // writes data from TempChunkData into region files
          /*if (!Engine.SaveVoxelData) {
           *  Debug.LogWarning ("Uniblocks: Saving is disabled. You can enable it in the Engine Settings.");
           *  return;
           * }*/

            // for each chunk object, save data to memory
            foreach (Chunk chunk in ChunkManager.Chunks.Values)
            {
                chunk.gameObject.GetComponent <ChunkDataFiles>().SaveData();
            }

            // write data to disk
            ChunkDataFiles.WriteLoadedChunks();

            Debug.Log("Uniblocks: World saved successfully. (Instant)");
        }