Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Cerios.Miner.Blocks;
- using Cerios.Miner.Worlds.Generation;
- using Cerios.Miner.Worlds.Location;
- namespace Cerios.Miner.Worlds
- {
- public class Chunk
- {
- /// <summary>
- /// The chunk side in world cordinates
- /// </summary>
- public const int ChunkSize = 16;
- /// <summary>
- /// Gets or sets the blocks in the Chunk
- /// </summary>
- public Block[] Blocks
- {
- get;
- set;
- }
- /// <summary>
- /// Gets or sets the location of the chunk
- /// </summary>
- public ChunkLocation Location
- {
- get;
- set;
- }
- /// <summary>
- /// The constructor
- /// </summary>
- /// <param name="location">The location of the chunk</param>
- public Chunk(ChunkLocation location)
- {
- Location = location;
- Blocks = new Block[ChunkSize * ChunkSize];
- }
- /// <summary>
- /// Generate the chunk
- /// </summary>
- /// <param name="generator">The generator to use</param>
- public void Generate(Generator generator)
- {
- for (int x = 0; x < ChunkSize; x++)
- for (int y = 0; y < ChunkSize; y++)
- {
- BlockChunkLocation blockChunkLocation = new BlockChunkLocation(x, y, Location);
- WorldLocation blockLocation = blockChunkLocation.GetWorldLocation();
- Blocks[x * ChunkSize + y] = generator.GetMaterialAtPosition(blockLocation.X, blockLocation.Y);
- Blocks[x * ChunkSize + y].Position = blockChunkLocation;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement