Esempio n. 1
0
        public Chunk(World world, ChunkPos pos)
        {
            this.WorldObj = world;
            this.Pos = pos;

            this.NeedsUpdate = true;

            this.Blocks = new byte[4096];
        }
        public Chunk GetChunk(ChunkPos pos)
        {
            Chunk chunk;
            this.LoadedChunks.TryGetValue(pos, out chunk);

            if (chunk == null)
            {
                chunk = this.LoadOrCreateChunk(pos);
                this.LoadedChunks.Add(pos, chunk);
            }

            return chunk;
        }
        public void Init()
        {
            this.Buffer = new VertexBuffer();

            var pos = new ChunkPos(0, 0, 0);
            var chunk = new Chunk(this.WorldObj, pos);

            for (int i = 0; i < 16; i++)
            {
                for (int j = 0; j < 1; j++)
                {
                    for (int k = 0; k < 16; k++)
                    {
                        chunk.SetBlock(BlockList.Stone, i, j, k);
                    }
                }
            }

            this.ChunkRenderers.Add(pos, new ChunkRenderer(chunk, this.WorldObj));

            this.Buffer.Upload();
        }
 public Chunk LoadOrCreateChunk(ChunkPos pos)
 {
     return new Chunk(this.WorldObj, pos);
 }