// Restores chunk from destroyed chunk data private IEnumerator RestoreChunk(Vector3 chunkPos) { ChunkGenerator restoredChunk = Instantiate(chunkGeneratorPrefab, chunkPos, Quaternion.identity, transform); restoredChunk.UpdateName(); chunkTable.Add(chunkPos, restoredChunk); restoredChunk.SetChunkSetup(); restoredChunk.SetBoxCollider(); yield return(restoredChunk.GenerateLoadedChunk(destroyedChunkData[chunkPos])); destroyedChunkData.Remove(chunkPos); }
// Creates chunk from save file data public IEnumerator CreateChunkByData(Vector3 chunkPos, WorldData.ChunkData chunkData) { ChunkGenerator newChunk = new ChunkGenerator(); newChunk = Instantiate(chunkGeneratorPrefab, chunkPos, Quaternion.identity, transform); newChunk.UpdateName(); if (!chunkTable.ContainsKey(chunkPos)) { chunkTable.Add(chunkPos, newChunk); newChunk.SetChunkSetup(); newChunk.SetBoxCollider(); yield return(newChunk.GenerateLoadedChunk(chunkData)); yield return(null); } }