summaryrefslogtreecommitdiff
path: root/src/world.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-08-27 03:33:50 -0500
committertom barrett <spalf0@gmail.com>2019-08-27 03:33:50 -0500
commit0f85752b1657e7b8024fb2715578712295979b3a (patch)
treed336db48ae288d08f23f89a56d01b9fa097c3a52 /src/world.rs
parentebf13bcd8e8ab799c56961e6bc1779bd8031a8dc (diff)
cargo update and dialogbox now disappears and npc resumes wandering
Diffstat (limited to 'src/world.rs')
-rw-r--r--src/world.rs15
1 files changed, 15 insertions, 0 deletions
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<DialogTree> {
let player_position = self.player.entity.position;
if let Some(npc) = self.npcs.iter_mut().find(|npc| {