diff --git a/src/map_builders/mod.rs b/src/map_builders/mod.rs index 44b9585..e1597d8 100644 --- a/src/map_builders/mod.rs +++ b/src/map_builders/mod.rs @@ -5,6 +5,7 @@ mod common; mod dla; mod drunkard; mod maze; +mod prefab_builder; mod simple_map; mod voronoi; mod waveform_collapse; diff --git a/src/map_builders/prefab_builder.rs b/src/map_builders/prefab_builder.rs new file mode 100644 index 0000000..1355fdf --- /dev/null +++ b/src/map_builders/prefab_builder.rs @@ -0,0 +1,65 @@ +use super::{remove_unreachable_areas_returning_most_distant, MapBuilder}; +use crate::{spawner, Map, Position, TileType, SHOW_MAPGEN_VISUALIZER}; +use rltk::RandomNumberGenerator; +use specs::prelude::*; + +#[derive(PartialEq, Clone)] +#[allow(dead_code)] +pub enum PrefabMode { + RexLevel { template: &'static str }, +} + +pub struct PrefabBuilder { + map: Map, + starting_position: Position, + depth: i32, + history: Vec, + mode: PrefabMode, +} + +impl MapBuilder for PrefabBuilder { + fn get_map(&self) -> Map { + self.map.clone() + } + + fn get_starting_position(&self) -> Position { + self.starting_position + } + + fn get_snapshot_history(&self) -> Vec { + self.history.clone() + } + + fn build_map(&mut self) { + self.build(); + } + + fn spawn_entities(&mut self, ecs: &mut World) {} + + fn take_snapshot(&mut self) { + if SHOW_MAPGEN_VISUALIZER { + let mut snapshot = self.map.clone(); + for v in snapshot.revealed_tiles.iter_mut() { + *v = true; + } + self.history.push(snapshot); + } + } +} + +impl PrefabBuilder { + #[allow(dead_code)] + pub fn new(new_depth: i32) -> PrefabBuilder { + PrefabBuilder { + map: Map::new(new_depth), + starting_position: Position { x: 0, y: 0 }, + depth: new_depth, + history: Vec::new(), + mode: PrefabMode::RexLevel { + template: "../resources/wfc-demo1.xp", + }, + } + } + + fn build(&mut self) {} +}