Add bsp interior

This commit is contained in:
2022-01-30 14:24:56 +01:00
parent c1893aec74
commit 5a00ebf1f1
11 changed files with 317 additions and 38 deletions

View File

@@ -6,12 +6,7 @@ use specs::saveload::{MarkedBuilder, SimpleMarker};
use crate::random_table::RandomTable;
use crate::rect::Rect;
use crate::{
AreaOfEffect, BlocksTile, CombatStats, Confusion, Consumable, DefenseBonus, EntryTrigger,
EquipmentSlot, Equippable, Hidden, HungerClock, HungerState, InflictsDamage, Item, MagicMapper,
MeleePowerBonus, Monster, Name, Player, Position, ProvidesFood, ProvidesHealing, Ranged,
Renderable, SerializeMe, SingleActivation, Viewshed, MAP_WIDTH, MAX_MONSTER,
};
use crate::{AreaOfEffect, BlocksTile, CombatStats, Confusion, Consumable, DefenseBonus, EntryTrigger, EquipmentSlot, Equippable, Hidden, HungerClock, HungerState, InflictsDamage, Item, MagicMapper, MeleePowerBonus, Monster, Name, Player, Position, ProvidesFood, ProvidesHealing, Ranged, Renderable, SerializeMe, SingleActivation, Viewshed, MAP_WIDTH, MAX_MONSTER, Map, TileType};
pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
ecs.create_entity()
@@ -86,7 +81,7 @@ fn monster<S: ToString>(ecs: &mut World, x: i32, y: i32, glyph: FontCharType, na
}
#[allow(clippy::map_entry)]
pub fn spawn_room(ecs: &mut World, room: &Rect, map_depth: i32) {
pub fn spawn_room(ecs: &mut World, room: &Rect, map_depth: i32, map: &Map) {
let spawn_table = room_table(map_depth);
let mut spawn_points: HashMap<usize, String> = HashMap::new();
@@ -101,7 +96,7 @@ pub fn spawn_room(ecs: &mut World, room: &Rect, map_depth: i32) {
let x = (room.x1 + rng.roll_dice(1, i32::abs(room.x2 - room.x1))) as usize;
let y = (room.y1 + rng.roll_dice(1, i32::abs(room.y2 - room.y1))) as usize;
let idx = (y * MAP_WIDTH) + x;
if !spawn_points.contains_key(&idx) {
if !spawn_points.contains_key(&idx) && map.tiles[idx] != TileType::Wall {
spawn_points.insert(idx, spawn_table.roll(&mut rng));
added = true;
} else {