implement showing names of conversation partners
This commit is contained in:
parent
eff6306a93
commit
c0672f0ad8
|
@ -11,6 +11,7 @@ pub const CHATS: &[&str] = &[
|
|||
pub const TOKEN_CHAT: &str = "chat";
|
||||
pub const TALKER_SPEED_FACTOR: f32 = 1.0 / 17.0;
|
||||
pub const CHAT_SPEED_MIN_LEN: f32 = 40.0;
|
||||
pub const NAME_FALLBACK: &str = "Unknown";
|
||||
|
||||
pub struct ChatPlugin;
|
||||
impl Plugin for ChatPlugin {
|
||||
|
@ -194,7 +195,7 @@ pub fn handle_chat_events(
|
|||
commands.entity(chat_entity).despawn();
|
||||
}
|
||||
ChatEvent::DisplayMessage(message) => {
|
||||
log.chat(message.into(), "Someone".to_string());
|
||||
log.chat(message.into(), chat.talker.name.clone().unwrap_or(NAME_FALLBACK.to_string()));
|
||||
chat.timer = now + ((message.len() as f32).max(CHAT_SPEED_MIN_LEN) * TALKER_SPEED_FACTOR * chat.talker.talking_speed) as f64;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue