private BiomeMerger createChunkBiome(float x, float z, int influence) { if (influence < 0) { throw new ArgumentException("Biome influence cannot be less than 0.", nameof(influence)); } BiomeMerger wrapper = new BiomeMerger(); for (int i = -influence; i <= influence; i++) { for (int j = -influence; j <= influence; j++) { //Surroundings wrapper.AddBiome(m_owner.GetBiome((int)(x + i), (int)(z + j))); } } return(wrapper); }
/// <summary> /// Build a height map using a noise method. /// </summary> public void BuildHeight() { //Build the chunk blocks for (int x = 0; x < ChunkSizeX; x++) { for (int z = 0; z < ChunkSizeZ; z++) { int worldX = (int)(x + m_gameObject.transform.position.x); int worldZ = (int)(z + m_gameObject.transform.position.z); BiomeMerger biome = createChunkBiome(worldX, worldZ, Influence); for (int y = 0; y < ChunkSizeY; y++) { Vector3 pos = new Vector3(x, y, z); int worldY = (int)(y + m_gameObject.transform.position.y); float value = biome.ComputeHeight(worldX, worldY, worldZ); //TODO: Apply the noise and the biome if (y < value) { Blocks[x, y, z] = new Block( biome.MainBiome.Block, pos, m_owner, this); } else { Blocks[x, y, z] = Block.Empty( pos, m_owner, this); } } } } State = ChunkState.Draw; }