26 lines
865 B
C#
26 lines
865 B
C#
using VoxelEngine.World.Blocks;
|
|
|
|
namespace VoxelEngine.World.WorldGen.Biomes;
|
|
|
|
public sealed class DesertBiome : IBiome
|
|
{
|
|
private readonly FastNoiseLite _detail;
|
|
|
|
public string Name => "Desert";
|
|
public SurfacePalette Surface { get; }
|
|
|
|
public DesertBiome(int seed, BlockRegistry blocks)
|
|
{
|
|
this._detail = new FastNoiseLite(seed + 101);
|
|
this._detail.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
|
this._detail.SetFrequency(0.015f);
|
|
this.Surface = new SurfacePalette(blocks.Sand, blocks.Sand, blocks.Stone);
|
|
}
|
|
|
|
public float SampleHeight(NoiseSource noise, float worldX, float worldZ)
|
|
=> WorldConstants.SeaLevel + 4f * noise.Continent(worldX, worldZ)
|
|
+ 1.5f * this._detail.GetNoise(worldX, worldZ);
|
|
|
|
public IBlock TopBlock(int worldY) => this.Surface.Top;
|
|
}
|