private void LoadChunk(Chunk chunk)
    {
        _terrainGenerator.GenerateBiomes(chunk, _seed);
        string file = Path.Combine(_toWorldSave, chunk.GetSaveFileName());

        if (File.Exists(file))
        {
            using FileStream stream   = new FileStream(file, FileMode.Open, FileAccess.Read);
            using BinaryReader reader = new BinaryReader(stream);

            SavedChunk chunkData = SavedChunk.ReadChunk(reader);

            reader.Close();

            chunk.OverrideChunkData(chunkData.ChunkData);

            int structuredChunks = Interlocked.Increment(ref _chunksStructured);
            if (structuredChunks >= _chunks.ChunkCount)
            {
                ChunkState = GlobalChunkState.InitialMeshing;
            }
        }
        else
        {
            _terrainGenerator.GenerateTerrain(chunk, _seed);

            int loadedChunks = Interlocked.Increment(ref _chunksLoaded);

            if (loadedChunks >= _chunks.ChunkCount)
            {
                ChunkState = GlobalChunkState.Structure;
            }
        }
    }
Esempio n. 2
0
    private void LoadChunk(Chunk chunk)
    {
        _terrainGenerator.GenerateBiomes(chunk, _seed);

        int loadedChunks = Interlocked.Increment(ref _chunksLoaded);

        if (loadedChunks >= _chunks.ChunkCount)
        {
            ChunkState = GlobalChunkState.Structure;
        }
    }