From 0f85752b1657e7b8024fb2715578712295979b3a Mon Sep 17 00:00:00 2001 From: tom barrett Date: Tue, 27 Aug 2019 03:33:50 -0500 Subject: cargo update and dialogbox now disappears and npc resumes wandering --- src/world.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/world.rs') diff --git a/src/world.rs b/src/world.rs index 76048b9..4e9a965 100644 --- a/src/world.rs +++ b/src/world.rs @@ -52,6 +52,21 @@ impl World { } } + pub fn player_in_talking_range(&mut self) -> bool { + if let Some(npc) = self.npcs.iter_mut().find(|npc| npc.is_talking()) { + if constants::INTERACT_DISTANCE + > distance(&self.player.entity.position, &npc.entity.position) + { + true + } else { + npc.stop_talking(); + false + } + } else { + false + } + } + pub fn get_dialogtree(&mut self) -> Option { let player_position = self.player.entity.position; if let Some(npc) = self.npcs.iter_mut().find(|npc| { -- cgit v1.2.3