Create prefab_builder
This commit is contained in:
parent
54e9e684e7
commit
def589086c
@ -5,6 +5,7 @@ mod common;
|
||||
mod dla;
|
||||
mod drunkard;
|
||||
mod maze;
|
||||
mod prefab_builder;
|
||||
mod simple_map;
|
||||
mod voronoi;
|
||||
mod waveform_collapse;
|
||||
|
65
src/map_builders/prefab_builder.rs
Normal file
65
src/map_builders/prefab_builder.rs
Normal 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) {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user