using VoxelEngine.Core; using VoxelEngine.World.Blocks; namespace VoxelEngine.World.WorldGen.Biomes; public sealed class MountainsBiome : IBiome { private readonly FastNoiseLite _ridged; private readonly IBlock _stone; private readonly IBlock _snow; private readonly Configuration _cfg; public string Name => "Mountains"; public SurfacePalette Surface { get; } public MountainsBiome(int seed, BlockRegistry blocks, Configuration cfg) { this._cfg = cfg; this._ridged = new FastNoiseLite(seed + 102); this._ridged.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); this._ridged.SetFractalType(FastNoiseLite.FractalType.Ridged); this._ridged.SetFractalOctaves(cfg.MountainsRidgedOctaves); this._ridged.SetFrequency(cfg.MountainsRidgedFrequency); 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 + this._cfg.MountainsContinentAmplitude * noise.Continent(worldX, worldZ) + this._cfg.MountainsRidgedAmplitude * this._ridged.GetNoise(worldX, worldZ); public IBlock TopBlock(int worldY) => worldY >= this._cfg.MountainsSnowLine ? this._snow : this._stone; }