use fastnoise_lite::{FastNoiseLite, FractalType}; use glam::IVec2; use crate::{ content::materials::MaterialId, proc_gen::{Biome, InterpolatedPixel, tileset_loader::TilePixelType}, sim::cell::Cell, }; const ROUGHNESS: f32 = 0.375; pub struct MinesBiome { pub edge_roughness: FastNoiseLite, } impl MinesBiome { pub fn new() -> Self { let mut edge_roughness = FastNoiseLite::new(); edge_roughness.set_fractal_type(Some(FractalType::Ridged)); edge_roughness.set_fractal_octaves(Some(2)); MinesBiome { edge_roughness } } } impl Biome for MinesBiome { fn fragment(&self, pixel: InterpolatedPixel, world: IVec2) -> Cell { let world = world.as_vec2(); let displacement = ROUGHNESS * self.edge_roughness.get_noise_2d(world.x, world.y); match pixel.interpolated_pixel_index { 0 => { if pixel.interpolated_solidity + displacement <= 0.0 { return Cell::void(); } Cell::from_material(MaterialId::Dirt) } 12 => { if pixel.interpolated_solidity + displacement <= 0.0 { return Cell::void(); } Cell::from_material(MaterialId::Water) } 13 => { if pixel.interpolated_solidity + displacement <= 0.0 { return Cell::void(); } Cell::from_material(MaterialId::Wood) } _ => Cell::void(), } } }