Added waypoint to dungeon staircases

This commit is contained in:
Joshua Barretto 2020-07-14 22:59:35 +01:00
parent 1763693f5f
commit cb660f47bb

View File

@ -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<i32>,
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;