public static NBTChunk LoadChunk(int chunkX, int chunkZ) { UnityEngine.Profiling.Profiler.BeginSample("ChunkChecker.Update"); key.Set(chunkX, chunkZ); if (!chunkDict.ContainsKey(key)) { TagNodeCompound Chunk = GetChunkNode(chunkX, chunkZ); if (Chunk != null) { TagNodeCompound Level = Chunk["Level"] as TagNodeCompound; TagNodeList Sections = Level["Sections"] as TagNodeList; NBTChunk chunk = ChunkPool.GetChunk(); chunk.SetData(chunkX, chunkZ, Sections); chunkDict.Add(key, chunk); } } UnityEngine.Profiling.Profiler.EndSample(); if (chunkDict.ContainsKey(key)) { return(chunkDict[key]); } return(null); }
public static async Task <NBTChunk> LoadChunkAsync(int chunkX, int chunkZ) { Vector2Int key = new Vector2Int(chunkX, chunkZ); if (!chunkDict.ContainsKey(key)) { TagNodeCompound Chunk = await GetChunkNodeAsync(chunkX, chunkZ); if (Chunk != null) { TagNodeCompound Level = Chunk["Level"] as TagNodeCompound; NBTChunk chunk = ChunkPool.GetChunk(); chunk.SetData(chunkX, chunkZ, Level); chunkDict.Add(key, chunk); } } if (chunkDict.ContainsKey(key)) { return(chunkDict[key]); } return(null); }