summaryrefslogtreecommitdiff
path: root/src/npc.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/npc.rs
parentebf13bcd8e8ab799c56961e6bc1779bd8031a8dc (diff)
cargo update and dialogbox now disappears and npc resumes wandering
Diffstat (limited to 'src/npc.rs')
-rw-r--r--src/npc.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/npc.rs b/src/npc.rs
index 29400a0..729aecd 100644
--- a/src/npc.rs
+++ b/src/npc.rs
@@ -116,6 +116,17 @@ impl NPC {
self.dialogtree.clone()
}
+ pub fn is_talking(&self) -> bool {
+ self.behavior == Behavior::Talking
+ }
+
+ pub fn stop_talking(&mut self) {
+ self.behavior = Behavior::Wandering(random_nearby_point(
+ self.entity.spawn,
+ constants::WANDER_DISTANCE,
+ ));
+ }
+
pub fn build_npcs(context: &mut Context, tileset: &Tileset, map: &Map) -> Vec<NPC> {
let mut npcs = Vec::new();
@@ -134,7 +145,7 @@ impl NPC {
}
}
-#[derive(Debug, Clone)]
+#[derive(Debug, Clone, PartialEq)]
enum Behavior {
Talking,
Waiting(Instant),