Add ability to spawn items and enemies in corridors
This commit is contained in:
parent
132d1dac62
commit
75d9af0562
@ -13,6 +13,7 @@ mod room_based_spawner;
|
||||
mod room_based_stairs;
|
||||
mod room_based_starting_position;
|
||||
mod room_corner_rounding;
|
||||
mod room_corridor_spawner;
|
||||
mod room_draw;
|
||||
mod room_exploder;
|
||||
mod room_sorter;
|
||||
@ -40,6 +41,7 @@ use room_based_spawner::RoomBasedSpawner;
|
||||
use room_based_stairs::RoomBasedStairs;
|
||||
use room_based_starting_position::RoomBasedStartingPosition;
|
||||
use room_corner_rounding::RoomCornerRounder;
|
||||
use room_corridor_spawner::CorridorSpawner;
|
||||
use room_draw::RoomDrawer;
|
||||
use room_exploder::RoomExploder;
|
||||
use room_sorter::{RoomSort, RoomSorter};
|
||||
|
30
src/map_builders/room_corridor_spawner.rs
Normal file
30
src/map_builders/room_corridor_spawner.rs
Normal file
@ -0,0 +1,30 @@
|
||||
use rltk::RandomNumberGenerator;
|
||||
|
||||
use super::{BuilderMap, MetaMapBuilder};
|
||||
use crate::spawner;
|
||||
|
||||
pub struct CorridorSpawner {}
|
||||
|
||||
impl MetaMapBuilder for CorridorSpawner {
|
||||
fn build_map(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) {
|
||||
self.build(rng, build_data);
|
||||
}
|
||||
}
|
||||
|
||||
impl CorridorSpawner {
|
||||
#[allow(dead_code)]
|
||||
pub fn new() -> Box<CorridorSpawner> {
|
||||
Box::new(CorridorSpawner {})
|
||||
}
|
||||
|
||||
fn build(&mut self, rng: &mut RandomNumberGenerator, build_data: &mut BuilderMap) {
|
||||
if let Some(corridors) = &build_data.corridors {
|
||||
for c in corridors.iter() {
|
||||
let depth = build_data.map.depth;
|
||||
spawner::spawn_region(&build_data.map, rng, &c, depth, &mut build_data.spawn_list);
|
||||
}
|
||||
} else {
|
||||
panic!("Corridor Based Spawning only works after corridors have been created.");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user