From 8e128d3ca24fa10dc7d871f7daf6c43eaddc385c Mon Sep 17 00:00:00 2001 From: Kai Stevenson Date: Sun, 30 Aug 2026 20:10:07 -0700 Subject: wip biome abstraction --- src/content/world/mines.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/content/world') diff --git a/src/content/world/mines.rs b/src/content/world/mines.rs index e69de29..ae859bc 100644 --- a/src/content/world/mines.rs +++ b/src/content/world/mines.rs @@ -0,0 +1,41 @@ +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 + } +} -- cgit v1.3.1