use crate::{ config::TILESET_SCALING, content::materials::MaterialId, proc_gen::{ Biome, tileset_loader::{Tile, TileOrientation, TilesetPixelType}, }, sim::cell::Cell, }; pub struct MinesBiome; impl Biome for MinesBiome { fn derive_world_from_tile(&self, tile: &Tile) -> Vec { let tp = TILESET_SCALING.pow(2) as u32; let mut cells = vec![Cell::void(); (tile.dimensions.short * tile.dimensions.long * tp) as usize]; let ey = match tile.orientation { TileOrientation::Horizontal => tile.dimensions.short, TileOrientation::Vertical => tile.dimensions.long, }; let ex = match tile.orientation { TileOrientation::Horizontal => tile.dimensions.long, TileOrientation::Vertical => tile.dimensions.short, }; for y in 0..ey { for x in 0..ex { let idx = (x + y * ex) * tp; for i in 0..tp { cells[(idx + i) as usize] = match tile.pixels[(x + y * ex) as usize] { TilesetPixelType::Void => Cell::void(), TilesetPixelType::Terrain => Cell::from_material(MaterialId::Dirt), } } } } cells } }