summaryrefslogtreecommitdiff
path: root/src/content/world/mines.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/content/world/mines.rs')
-rw-r--r--src/content/world/mines.rs41
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
+ }
+}