From def589086c09d32f7f97eeadf4f6686b9c7a12e3 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Fri, 10 Dec 2021 11:31:39 -0500 Subject: [PATCH] Create prefab_builder --- src/map_builders/mod.rs | 1 + src/map_builders/prefab_builder.rs | 65 ++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 src/map_builders/prefab_builder.rs 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) {} +}