Example #1
0
 /// <summary>
 ///     Set the World's WorldInfo.
 /// </summary>
 /// <param name="info">WorldInfo object to set to.</param>
 public void SetWorldInfo(WorldInfo info)
 {
     worldInfo = info;
 }
Example #2
0
        public static async Task SaveWorldInfo(WorldInfo worldInfo)
        {
            string savePath = GetWorldSavePath(worldInfo.GetId());

            await SaveWorldInfoAt(worldInfo, savePath);
        }
Example #3
0
        // TODO: Make <summary>s for every method here

        /// <summary>
        ///     Get all the chunks that have a corresponding save file.
        /// </summary>
        /// <param name="chunkPos">The chunks to check.</param>
        /// <param name="worldInfo">The world to check in.</param>
        /// <returns>Returns ALL chunks that exist; if a chunk does not exist, it is not included.</returns>
        public static List <Vector3Int> GetExistingChunks(List <Vector3Int> chunkPos, WorldInfo worldInfo)
        {
            // TODO: Check if this needs to run on a separate thread/Task
            string savePath   = GetWorldSavePath(worldInfo.GetId());
            string chunksPath = Path.Combine(savePath, "chunks");

            List <Vector3Int> resultPos = new List <Vector3Int>();

            foreach (Vector3Int pos in chunkPos)
            {
                string chunkPath = Path.Combine(chunksPath,
                                                $"{Chunk.GetIdForPosition(pos)}.dat");

                if (File.Exists(chunkPath))
                {
                    resultPos.Add(pos);
                }
            }

            return(resultPos);
        }
Example #4
0
        public static async Task <List <Chunk> > LoadChunk(List <Vector3Int> chunkPos, WorldInfo worldInfo)
        {
            string savePath = GetWorldSavePath(worldInfo.GetId());

            return(await LoadChunkAt(chunkPos, savePath));
        }
Example #5
0
        public static async Task SaveChunks(List <Chunk> chunks, WorldInfo worldInfo, bool debugMode = false)
        {
            string savePath = GetWorldSavePath(worldInfo.GetId());

            await SaveChunksAt(chunks, savePath, debugMode);
        }