prevent multiple chats with the same person
This commit is contained in:
parent
029a53c115
commit
2f19df9f95
2 changed files with 15 additions and 3 deletions
|
@ -20,7 +20,7 @@
|
|||
id: "hialien",
|
||||
name: "Icarus",
|
||||
label: "requested",
|
||||
delay: 5.0,
|
||||
delay: 8.0,
|
||||
sound: "chat",
|
||||
reply: "Oh hey there, didn't even notice you! Was playing some VR game! What's up?",
|
||||
goto: "reply1",
|
||||
|
|
16
src/actor.rs
16
src/actor.rs
|
@ -182,12 +182,24 @@ pub fn handle_input(
|
|||
pub fn handle_new_conversations(
|
||||
mut commands: Commands,
|
||||
mut er_conv: EventReader<StartConversationEvent>,
|
||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||
q_conv: Query<&Chat>,
|
||||
time: Res<Time>,
|
||||
) {
|
||||
let id = "hialien";
|
||||
let label = "INIT";
|
||||
for _my_event in er_conv.read() {
|
||||
// check for existing chats with this id
|
||||
let chats: Vec<&Chat> = q_conv.iter().filter(|c| c.id == id).collect();
|
||||
if chats.len() > 0 {
|
||||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Ping));
|
||||
continue;
|
||||
}
|
||||
|
||||
// no existing chats yet, let's create a new one
|
||||
commands.spawn(Chat {
|
||||
id: "hialien".to_string(),
|
||||
label: "INIT".to_string(),
|
||||
id: id.to_string(),
|
||||
label: label.to_string(),
|
||||
timer: time.elapsed_seconds_f64(),
|
||||
});
|
||||
break;
|
||||
|
|
Loading…
Add table
Reference in a new issue