33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
using VoxelEngine.World.Blocks;
|
|
|
|
namespace VoxelEngine.World.WorldGen.Biomes;
|
|
|
|
public sealed class MountainsBiome : IBiome
|
|
{
|
|
private const int SnowLine = 384;
|
|
private readonly FastNoiseLite _ridged;
|
|
private readonly IBlock _stone;
|
|
private readonly IBlock _snow;
|
|
|
|
public string Name => "Mountains";
|
|
public SurfacePalette Surface { get; }
|
|
|
|
public MountainsBiome(int seed, BlockRegistry blocks)
|
|
{
|
|
this._ridged = new FastNoiseLite(seed + 102);
|
|
this._ridged.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
|
|
this._ridged.SetFractalType(FastNoiseLite.FractalType.Ridged);
|
|
this._ridged.SetFractalOctaves(4);
|
|
this._ridged.SetFrequency(0.01f);
|
|
this._stone = blocks.Stone;
|
|
this._snow = blocks.Snow;
|
|
this.Surface = new SurfacePalette(blocks.Stone, blocks.Stone, blocks.Stone);
|
|
}
|
|
|
|
public float SampleHeight(NoiseSource noise, float worldX, float worldZ)
|
|
=> WorldConstants.SeaLevel + 40f * noise.Continent(worldX, worldZ)
|
|
+ 200f * this._ridged.GetNoise(worldX, worldZ);
|
|
|
|
public IBlock TopBlock(int worldY) => worldY >= MountainsBiome.SnowLine ? this._snow : this._stone;
|
|
}
|