FillEdges builder, and a welcome message
This commit is contained in:
parent
0fe866c048
commit
b80c3ac9d1
5 changed files with 54 additions and 11 deletions
|
|
@ -43,13 +43,7 @@ pub fn setup_log() {
|
||||||
for _ in 0..5 {
|
for _ in 0..5 {
|
||||||
Logger::new().log();
|
Logger::new().log();
|
||||||
}
|
}
|
||||||
Logger::new()
|
Logger::new().append("Welcome!").colour(rltk::CYAN).append("Press [?] at any time to view controls").period().log();
|
||||||
.append("Welcome!")
|
|
||||||
.colour(rltk::CYAN)
|
|
||||||
.append("(")
|
|
||||||
.append("pretend i wrote a paragraph explaining why you're here")
|
|
||||||
.append(")")
|
|
||||||
.log();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clone_log() -> Vec<Vec<crate::gamelog::LogFragment>> {
|
pub fn clone_log() -> Vec<Vec<crate::gamelog::LogFragment>> {
|
||||||
|
|
|
||||||
35
src/map_builders/fill_edges.rs
Normal file
35
src/map_builders/fill_edges.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
use super::{BuilderMap, MetaMapBuilder, TileType};
|
||||||
|
use rltk::RandomNumberGenerator;
|
||||||
|
|
||||||
|
pub struct FillEdges {
|
||||||
|
fill_with: TileType,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MetaMapBuilder for FillEdges {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
fn build_map(&mut self, rng: &mut rltk::RandomNumberGenerator, build_data: &mut BuilderMap) {
|
||||||
|
self.fill_edges(rng, build_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FillEdges {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn wall() -> Box<FillEdges> {
|
||||||
|
return Box::new(FillEdges { fill_with: TileType::Wall });
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fill_edges(&mut self, _rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) {
|
||||||
|
for x in 0..build_data.map.width {
|
||||||
|
let mut idx = build_data.map.xy_idx(x, 0);
|
||||||
|
build_data.map.tiles[idx] = self.fill_with;
|
||||||
|
idx = build_data.map.xy_idx(x, build_data.map.height - 1);
|
||||||
|
build_data.map.tiles[idx] = self.fill_with;
|
||||||
|
}
|
||||||
|
for y in 0..build_data.map.height {
|
||||||
|
let mut idx = build_data.map.xy_idx(0, y);
|
||||||
|
build_data.map.tiles[idx] = self.fill_with;
|
||||||
|
idx = build_data.map.xy_idx(build_data.map.width - 1, y);
|
||||||
|
build_data.map.tiles[idx] = self.fill_with;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -56,6 +56,8 @@ mod rooms_corridors_spawner;
|
||||||
use rooms_corridors_spawner::CorridorSpawner;
|
use rooms_corridors_spawner::CorridorSpawner;
|
||||||
mod door_placement;
|
mod door_placement;
|
||||||
use door_placement::DoorPlacement;
|
use door_placement::DoorPlacement;
|
||||||
|
mod fill_edges;
|
||||||
|
use fill_edges::FillEdges;
|
||||||
|
|
||||||
// Shared data to be passed around build chain
|
// Shared data to be passed around build chain
|
||||||
pub struct BuilderMap {
|
pub struct BuilderMap {
|
||||||
|
|
@ -283,8 +285,12 @@ pub fn random_builder(new_depth: i32, rng: &mut rltk::RandomNumberGenerator, wid
|
||||||
_ => random_shape_builder(rng, &mut builder),
|
_ => random_shape_builder(rng, &mut builder),
|
||||||
}
|
}
|
||||||
|
|
||||||
/*if rng.roll_dice(1, 3)==1 {
|
/*
|
||||||
builder.with(WaveformCollapseBuilder::new());
|
WFC needs polishing up before it makes good maps. Right now it leaves too much unusable area,
|
||||||
|
by making disconnected sections and having no methods to connect them.
|
||||||
|
|
||||||
|
if rng.roll_dice(1, 1) == 1 {
|
||||||
|
builder.with(WaveFunctionCollapseBuilder::new());
|
||||||
|
|
||||||
// Now set the start to a random starting area
|
// Now set the start to a random starting area
|
||||||
let (start_x, start_y) = random_start_position(rng);
|
let (start_x, start_y) = random_start_position(rng);
|
||||||
|
|
@ -293,7 +299,8 @@ pub fn random_builder(new_depth: i32, rng: &mut rltk::RandomNumberGenerator, wid
|
||||||
// Setup an exit and spawn mobs
|
// Setup an exit and spawn mobs
|
||||||
builder.with(VoronoiSpawning::new());
|
builder.with(VoronoiSpawning::new());
|
||||||
builder.with(DistantExit::new());
|
builder.with(DistantExit::new());
|
||||||
}*/
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if rng.roll_dice(1, 20) == 1 {
|
if rng.roll_dice(1, 20) == 1 {
|
||||||
builder.with(PrefabBuilder::sectional(prefab_builder::prefab_sections::UNDERGROUND_FORT));
|
builder.with(PrefabBuilder::sectional(prefab_builder::prefab_sections::UNDERGROUND_FORT));
|
||||||
|
|
@ -301,6 +308,9 @@ pub fn random_builder(new_depth: i32, rng: &mut rltk::RandomNumberGenerator, wid
|
||||||
|
|
||||||
builder.with(DoorPlacement::new());
|
builder.with(DoorPlacement::new());
|
||||||
builder.with(PrefabBuilder::vaults());
|
builder.with(PrefabBuilder::vaults());
|
||||||
|
// Regardless of anything else, fill the edges back in with walls. We can't walk
|
||||||
|
// there anyway, and we don't want an open line of sight into the unmapped void.
|
||||||
|
builder.with(FillEdges::wall());
|
||||||
|
|
||||||
builder
|
builder
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,10 @@ impl PrefabBuilder {
|
||||||
build_data.map.tiles[idx] = TileType::Floor;
|
build_data.map.tiles[idx] = TileType::Floor;
|
||||||
build_data.starting_position = Some(Position { x: x as i32, y: y as i32 });
|
build_data.starting_position = Some(Position { x: x as i32, y: y as i32 });
|
||||||
}
|
}
|
||||||
|
'+' => {
|
||||||
|
build_data.map.tiles[idx] = TileType::Floor;
|
||||||
|
build_data.spawn_list.push((idx, "door".to_string()));
|
||||||
|
}
|
||||||
'g' => {
|
'g' => {
|
||||||
build_data.map.tiles[idx] = TileType::Floor;
|
build_data.map.tiles[idx] = TileType::Floor;
|
||||||
build_data.spawn_list.push((idx, "goblin".to_string()));
|
build_data.spawn_list.push((idx, "goblin".to_string()));
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ pub fn scroll_table(_map_depth: i32) -> RandomTable {
|
||||||
.add("fireball scroll", 2)
|
.add("fireball scroll", 2)
|
||||||
.add("cursed fireball scroll", 2)
|
.add("cursed fireball scroll", 2)
|
||||||
.add("confusion scroll", 4)
|
.add("confusion scroll", 4)
|
||||||
.add("magic missile scroll", 10)
|
.add("magic missile scroll", 6)
|
||||||
.add("magic map scroll", 4)
|
.add("magic map scroll", 4)
|
||||||
.add("cursed magic map scroll", 2);
|
.add("cursed magic map scroll", 2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue