From cb660f47bba6cd2a501944fff605975bf9501824 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Tue, 14 Jul 2020 22:59:35 +0100 Subject: [PATCH] Added waypoint to dungeon staircases --- world/src/site/dungeon/mod.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/world/src/site/dungeon/mod.rs b/world/src/site/dungeon/mod.rs index aafe012415..201b06d371 100644 --- a/world/src/site/dungeon/mod.rs +++ b/world/src/site/dungeon/mod.rs @@ -151,20 +151,6 @@ impl Dungeon { max: rpos + TerrainChunkSize::RECT_SIZE.map(|e| e as i32), }; - if area.contains_point(Vec2::zero()) { - let offs = Vec2::new(rng.gen_range(-1.0, 1.0), rng.gen_range(-1.0, 1.0)) - .try_normalized() - .unwrap_or(Vec2::unit_y()) - * 12.0; - supplement.add_entity( - EntityInfo::at( - Vec3::new(self.origin.x, self.origin.y, self.alt + 16).map(|e| e as f32) - + Vec3::from(offs), - ) - .into_waypoint(), - ); - } - let mut z = self.alt + ALT_OFFSET; for floor in &self.floors { z -= floor.total_depth(); @@ -410,6 +396,20 @@ impl Floor { origin: Vec3, supplement: &mut ChunkSupplement, ) { + let stair_rcenter = Vec3::from((self.stair_tile + self.tile_offset) + .map(|e| e * TILE_SIZE + TILE_SIZE / 2)); + + if area.contains_point(stair_rcenter.xy()) { + let offs = Vec2::new(rng.gen_range(-1.0, 1.0), rng.gen_range(-1.0, 1.0)) + .try_normalized() + .unwrap_or(Vec2::unit_y()) + * FLOOR_SIZE.x as f32 / 2.0 - 8.0; + supplement.add_entity( + EntityInfo::at((origin + stair_rcenter).map(|e| e as f32) + Vec3::from(offs)) + .into_waypoint() + ); + } + for x in area.min.x..area.max.x { for y in area.min.y..area.max.y { let tile_pos = Vec2::new(x, y).map(|e| e.div_euclid(TILE_SIZE)) - self.tile_offset;