Created
May 6, 2016 19:08
-
-
Save Brian1KB/ca4ca14c6cdee92881c20358ae1dd12b to your computer and use it in GitHub Desktop.
Creates framing chunks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | |
{ | |
ChunkColumn surroundingChunkColumn; | |
_chunkCache.TryGetValue(surroundingChunkCoordinates, out surroundingChunkColumn); | |
if (surroundingChunkColumn == null) | |
{ | |
ChunkColumn airColumn = new ChunkColumn | |
{ | |
x = startX, | |
z = startZ, | |
isAllAir = true | |
}; | |
airColumn.GetBatch(); | |
_chunkCache[chunkCoordinates] = airColumn; | |
createdChunks++; | |
} | |
} | |
} | |
} | |
} | |
} | |
sw.Stop(); | |
Log.Info("Created " + createdChunks + " air chunks in " + sw.ElapsedMilliseconds + "ms"); | |
return createdChunks; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment