diff options
| author | Kai Stevenson <kai@kaistevenson.com> | 2026-08-30 20:10:07 -0700 |
|---|---|---|
| committer | Kai Stevenson <kai@kaistevenson.com> | 2026-08-30 20:10:07 -0700 |
| commit | 8e128d3ca24fa10dc7d871f7daf6c43eaddc385c (patch) | |
| tree | c4b32bfb559941041965418daefda1deffafd8e9 /src/content/world/mines.rs | |
| parent | 56bba5560be95c1e05bfec11e4fc085654f3589d (diff) | |
wip biome abstraction
Diffstat (limited to 'src/content/world/mines.rs')
| -rw-r--r-- | src/content/world/mines.rs | 41 |
1 files changed, 41 insertions, 0 deletions
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<Cell> { + 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 + } +} |
