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/npc.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/npc.rs') 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 { let mut npcs = Vec::new(); @@ -134,7 +145,7 @@ impl NPC { } } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] enum Behavior { Talking, Waiting(Instant), -- cgit v1.2.3