public int MakeAirChunksAroundWorldToCompensateForBadRendering() { var createdChunks = 0; var sw = new Stopwatch(); sw.Start(); foreach (AnvilChunk chunkColumn in GetAllChunks()) { var chunkCoordinates = new ChunkCoordinates(chunkColumn.x, chunkColumn.z); if (chunkColumn != null && !chunkColumn.isAllAir) { for (int startX = chunkCoordinates.X - 1; startX <= chunkCoordinates.X + 1; startX++) { for (int startZ = chunkCoordinates.Z - 1; startZ <= chunkCoordinates.Z + 1; startZ++) { var surroundingChunkCoordinates = new ChunkCoordinates(startX, startZ); if (surroundingChunkCoordinates.Equals(chunkCoordinates)) { continue; } ChunkColumn surroundingChunkColumn = GenerateChunkColumn(surroundingChunkCoordinates); } } } } sw.Stop(); Debug.WriteLine("Created " + createdChunks + " air chunks in " + sw.ElapsedMilliseconds + "ms"); return(createdChunks); }
public int MakeAirChunksAroundWorldToCompensateForBadRendering() { int createdChunks = 0; Stopwatch sw = new Stopwatch(); sw.Start(); foreach (KeyValuePair <ChunkCoordinates, ChunkColumn> valuePair in _chunkCache) { ChunkCoordinates chunkCoordinates = valuePair.Key; ChunkColumn chunkColumn = valuePair.Value; if (chunkColumn != null && !chunkColumn.isAllAir) { for (int startX = chunkCoordinates.X - 1; startX <= chunkCoordinates.X + 1; startX++) { for (int startZ = chunkCoordinates.Z - 1; startZ <= chunkCoordinates.Z + 1; startZ++) { ChunkCoordinates surroundingChunkCoordinates = new ChunkCoordinates(startX, startZ); if (surroundingChunkCoordinates.Equals(chunkCoordinates)) { continue; } ChunkColumn surroundingChunkColumn; _chunkCache.TryGetValue(surroundingChunkCoordinates, out surroundingChunkColumn); if (surroundingChunkColumn == null) { ChunkColumn airColumn = new ChunkColumn { x = startX, z = startZ, isAllAir = true }; airColumn.GetBatch(); _chunkCache[surroundingChunkCoordinates] = airColumn; createdChunks++; } } } } } sw.Stop(); Log.Info("Created " + createdChunks + " air chunks in " + sw.ElapsedMilliseconds + "ms"); return(createdChunks); }
public int PruneAir() { int prunedChunks = 0; Stopwatch sw = new Stopwatch(); sw.Start(); foreach (KeyValuePair <ChunkCoordinates, ChunkColumn> valuePair in _chunkCache) { ChunkCoordinates chunkCoordinates = valuePair.Key; ChunkColumn chunkColumn = valuePair.Value; if (chunkColumn != null && chunkColumn.isAllAir) { bool surroundingIsAir = true; for (int startX = chunkCoordinates.X - 1; startX <= chunkCoordinates.X + 1; startX++) { for (int startZ = chunkCoordinates.Z - 1; startZ <= chunkCoordinates.Z + 1; startZ++) { ChunkCoordinates surroundingChunkCoordinates = new ChunkCoordinates(startX, startZ); if (!surroundingChunkCoordinates.Equals(chunkCoordinates)) { ChunkColumn surroundingChunkColumn; _chunkCache.TryGetValue(surroundingChunkCoordinates, out surroundingChunkColumn); if (surroundingChunkColumn != null && !surroundingChunkColumn.isAllAir) { surroundingIsAir = false; break; } } } } if (surroundingIsAir) { _chunkCache[chunkCoordinates] = null; prunedChunks++; } } } sw.Stop(); Log.Info("Pruned " + prunedChunks + " in " + sw.ElapsedMilliseconds + "ms"); return(prunedChunks); }
public int PruneAir() { var prunedChunks = 0; var sw = new Stopwatch(); sw.Start(); foreach (AnvilChunk chunkColumn in GetAllChunks()) { var chunkCoordinates = new ChunkCoordinates(chunkColumn.x, chunkColumn.z); if (chunkColumn != null && chunkColumn.isAllAir) { var surroundingIsAir = true; for (int startX = chunkCoordinates.X - 1; startX <= chunkCoordinates.X + 1; startX++) { for (int startZ = chunkCoordinates.Z - 1; startZ <= chunkCoordinates.Z + 1; startZ++) { var surroundingChunkCoordinates = new ChunkCoordinates(startX, startZ); if (!surroundingChunkCoordinates.Equals(chunkCoordinates)) { ChunkColumn surroundingChunkColumn = GetChunkColumn(surroundingChunkCoordinates); if (surroundingChunkColumn != null && !surroundingChunkColumn.isAllAir) { surroundingIsAir = false; break; } } } } if (surroundingIsAir) { DeleteChunkColumn(chunkCoordinates); prunedChunks++; } } } sw.Stop(); Debug.WriteLine("Pruned " + prunedChunks + " in " + sw.ElapsedMilliseconds + "ms"); return(prunedChunks); }