Exemplo n.º 1
0
 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}");
         }
     }
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 protected virtual void OnChunkLoaded(int chunkNumber, int chunkBytes)
 {
     ChunkLoaded?.Invoke(this, chunkNumber, chunkBytes);
 }