summaryrefslogtreecommitdiff
path: root/src/world.rs
diff options
context:
space:
mode:
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| {