/// <summary> /// Get's the chunk object at pos /// </summary> /// <param name="pos">Position of the chunk or of a block within the chunk</param> /// <returns>chunk that contains the given block position or null if there is none</returns> public Chunk GetChunk(BlockPos pos) { //Get the coordinates of the chunk containing this block pos = pos.ContainingChunkCoordinates(); Chunk containerChunk = null; chunks.TryGetValue(pos, out containerChunk); return(containerChunk); }
/// <summary> /// Updates any chunks neighboring a block position /// </summary> /// <param name="pos">position of change</param> public void UpdateAdjacentChunks(BlockPos pos) { BlockPos localPos = pos - pos.ContainingChunkCoordinates(); //Checks to see if the block position is on the border of the chunk //and if so update the chunk it's touching UpdateIfEqual(localPos.x, 0, pos.Add(-1, 0, 0)); UpdateIfEqual(localPos.x, Config.Env.ChunkSize - 1, pos.Add(1, 0, 0)); UpdateIfEqual(localPos.y, 0, pos.Add(0, -1, 0)); UpdateIfEqual(localPos.y, Config.Env.ChunkSize - 1, pos.Add(0, 1, 0)); UpdateIfEqual(localPos.z, 0, pos.Add(0, 0, -1)); UpdateIfEqual(localPos.z, Config.Env.ChunkSize - 1, pos.Add(0, 0, 1)); }
/// <summary> /// Updates any chunks neighboring a block position /// </summary> /// <param name="pos">position of change</param> public void UpdateAdjacentChunks(BlockPos pos) { BlockPos localPos = pos - pos.ContainingChunkCoordinates(); //Checks to see if the block position is on the border of the chunk //and if so update the chunk it's touching UpdateIfEqual(localPos.x, 0, pos.Add(-1, 0, 0)); UpdateIfEqual(localPos.x, Config.Env.ChunkSize - 1, pos.Add(1, 0, 0)); UpdateIfEqual(localPos.y, 0, pos.Add(0, -1, 0)); UpdateIfEqual(localPos.y, Config.Env.ChunkSize - 1, pos.Add(0, 1, 0)); UpdateIfEqual(localPos.z, 0, pos.Add(0, 0, -1)); UpdateIfEqual(localPos.z, Config.Env.ChunkSize - 1, pos.Add(0, 0, 1)); }
/// <summary> /// Get's the chunk object at pos /// </summary> /// <param name="pos">Position of the chunk or of a block within the chunk</param> /// <returns>chunk that contains the given block position or null if there is none</returns> public Chunk GetChunk(BlockPos pos) { //Get the coordinates of the chunk containing this block pos = pos.ContainingChunkCoordinates(); Chunk containerChunk = null; chunks.TryGetValue(pos, out containerChunk); return containerChunk; }
public void SaveCompleteForChunk(BlockPos pos) { chunksToSave.Remove(pos.ContainingChunkCoordinates()); progress = Mathf.FloorToInt(((totalChunksToSave - chunksToSave.Count) / ((float)totalChunksToSave)) * 100); }
public void SaveCompleteForChunk(BlockPos pos) { chunksToSave.Remove(pos.ContainingChunkCoordinates()); progress = Mathf.FloorToInt(((totalChunksToSave - chunksToSave.Count) / ((float)totalChunksToSave)) * 100); }