Beispiel #1
0
        public static async Task SaveWorld(World world)
        {
            WorldInfo info     = world.GetWorldInfo();
            string    savePath = GetWorldSavePath(info.GetId());

            await SaveWorldAt(world, savePath);
        }
Beispiel #2
0
        public static async Task LoadWorld(string id, World world)
        {
            WorldInfo info     = world.GetWorldInfo();
            string    savePath = GetWorldSavePath(info.GetId());

            await LoadWorldAt(savePath, world);
        }
Beispiel #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);
        }
Beispiel #4
0
        public static async Task SaveWorldInfo(WorldInfo worldInfo)
        {
            string savePath = GetWorldSavePath(worldInfo.GetId());

            await SaveWorldInfoAt(worldInfo, savePath);
        }
Beispiel #5
0
        public static async Task <List <Chunk> > LoadChunk(List <Vector3Int> chunkPos, WorldInfo worldInfo)
        {
            string savePath = GetWorldSavePath(worldInfo.GetId());

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

            await SaveChunksAt(chunks, savePath, debugMode);
        }