public void Generate() { for (int x = 0; x < 2; x++) { for (int y = 0; y < 2; y++) { var tiles = MapGenerator.GenerateChunk(x, y, _chunkSize, _chunkSize, 1); var pos = new IntVector(x, y); var chunk = new MapChunk(pos, new IntVector(_chunkSize, _chunkSize), tiles); _chunks[pos] = chunk; ChunkLoaded?.Invoke(chunk); Console.WriteLine($"Generated chunk {pos} at {chunk.MapOffset}"); } } }
public void LoadChunk(ChunkPosition position) { if (IsLoaded(position)) { Logger.Warn("Trying to load an already loaded chunk at {0}", position); return; } // TODO use Client's adapter var version = GameAdapters.CurrentVersion; var adapter = GameAdapters.Resolve(version.Protocol); var chunk = RenderChunk(position, new GlobalBlockPalette(adapter.BlockRegistry)); _loadedChunks[position] = chunk; _client.Connection.LoadChunk(position, chunk); ChunkLoaded?.Invoke(this, new ChunkEventArgs(position, chunk)); }
protected virtual void OnChunkLoaded(int chunkNumber, int chunkBytes) { ChunkLoaded?.Invoke(this, chunkNumber, chunkBytes); }