diffusion-limited aggregation, symmetry, brushes

This commit is contained in:
Llywelwyn 2023-07-19 20:15:26 +01:00
parent 6b86b8f251
commit 09bafa4d1f
4 changed files with 365 additions and 17 deletions

View file

@ -1,6 +1,6 @@
use super::{
generate_voronoi_spawn_regions, remove_unreachable_areas_returning_most_distant, spawner, Map, MapBuilder,
Position, TileType, SHOW_MAPGEN,
generate_voronoi_spawn_regions, paint, remove_unreachable_areas_returning_most_distant, spawner, Map, MapBuilder,
Position, Symmetry, TileType, SHOW_MAPGEN,
};
use rltk::RandomNumberGenerator;
use specs::prelude::*;
@ -16,6 +16,8 @@ pub struct DrunkardSettings {
pub spawn_mode: DrunkSpawnMode,
pub drunken_lifetime: i32,
pub floor_percent: f32,
pub brush_size: i32,
pub symmetry: Symmetry,
}
pub struct DrunkardsWalkBuilder {
@ -59,17 +61,6 @@ impl MapBuilder for DrunkardsWalkBuilder {
}
impl DrunkardsWalkBuilder {
pub fn new(new_depth: i32, settings: DrunkardSettings) -> DrunkardsWalkBuilder {
DrunkardsWalkBuilder {
map: Map::new(new_depth),
starting_position: Position { x: 0, y: 0 },
depth: new_depth,
history: Vec::new(),
noise_areas: HashMap::new(),
settings,
}
}
pub fn open_area(new_depth: i32) -> DrunkardsWalkBuilder {
DrunkardsWalkBuilder {
map: Map::new(new_depth),
@ -81,6 +72,8 @@ impl DrunkardsWalkBuilder {
spawn_mode: DrunkSpawnMode::StartingPoint,
drunken_lifetime: 400,
floor_percent: 0.5,
brush_size: 1,
symmetry: Symmetry::None,
},
}
}
@ -96,6 +89,8 @@ impl DrunkardsWalkBuilder {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 400,
floor_percent: 0.5,
brush_size: 1,
symmetry: Symmetry::None,
},
}
}
@ -111,6 +106,42 @@ impl DrunkardsWalkBuilder {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 100,
floor_percent: 0.4,
brush_size: 1,
symmetry: Symmetry::None,
},
}
}
pub fn fat_passages(new_depth: i32) -> DrunkardsWalkBuilder {
DrunkardsWalkBuilder {
map: Map::new(new_depth),
starting_position: Position { x: 0, y: 0 },
depth: new_depth,
history: Vec::new(),
noise_areas: HashMap::new(),
settings: DrunkardSettings {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 100,
floor_percent: 0.4,
brush_size: 2,
symmetry: Symmetry::None,
},
}
}
pub fn fearful_symmetry(new_depth: i32) -> DrunkardsWalkBuilder {
DrunkardsWalkBuilder {
map: Map::new(new_depth),
starting_position: Position { x: 0, y: 0 },
depth: new_depth,
history: Vec::new(),
noise_areas: HashMap::new(),
settings: DrunkardSettings {
spawn_mode: DrunkSpawnMode::Random,
drunken_lifetime: 100,
floor_percent: 0.4,
brush_size: 1,
symmetry: Symmetry::Both,
},
}
}
@ -154,6 +185,7 @@ impl DrunkardsWalkBuilder {
if self.map.tiles[drunk_idx] == TileType::Wall {
did_something = true;
}
paint(&mut self.map, self.settings.symmetry, self.settings.brush_size, drunk_x, drunk_y);
self.map.tiles[drunk_idx] = TileType::DownStair;
let stagger_direction = rng.roll_dice(1, 4);