1
0
Fork 0

Create prefab_builder

This commit is contained in:
Timothy Warren 2021-12-10 11:31:39 -05:00
parent 54e9e684e7
commit def589086c
2 changed files with 66 additions and 0 deletions

View File

@ -5,6 +5,7 @@ mod common;
mod dla;
mod drunkard;
mod maze;
mod prefab_builder;
mod simple_map;
mod voronoi;
mod waveform_collapse;

View File

@ -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<Map>,
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<Map> {
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) {}
}