use bevy::prelude::*; use crate::{actor, audio, hud, settings}; pub struct ChatPlugin; impl Plugin for ChatPlugin { fn build(&self, app: &mut App) { app.register_type::(); app.add_systems(Update, ( handle_new_conversations, handle_reply_keys, handle_send_messages, handle_conversations, handle_chat_scripts, )); app.add_systems(PostUpdate, despawn_old_choices); app.add_event::(); app.add_event::(); app.add_event::(); } } #[derive(Event)] pub struct StartConversationEvent { pub talker: Talker, } #[derive(Event)] pub struct SendMessageEvent { pub conv_id: String, pub conv_label: String, pub text: String, } #[derive(Event)] pub struct ChatScriptEvent { name: String, param: String, param2: String, } #[derive(Debug)] #[derive(Component, Reflect, Default)] #[reflect(Component)] pub struct ChatBranch { pub id: String, pub name: String, pub label: String, pub delay: f64, pub sound: String, pub level: String, pub reply: String, pub goto: String, pub choice: String, pub script: String, pub script_parameter: String, pub script_parameter2: String, } #[derive(Component)] pub struct Chat { pub id: String, pub label: String, pub timer: f64, } #[derive(Component)] pub struct ChoiceAvailable { pub conv_id: String, pub conv_label: String, pub recipient: String, pub text: String, } #[derive(Component)] #[derive(Clone)] pub struct Talker { pub pronoun: String, pub conv_id: String, } impl Default for Talker { fn default() -> Self { Self { pronoun: "they/them".to_string(), conv_id: "error".to_string(), }}} pub fn handle_new_conversations( mut commands: Commands, mut er_conv: EventReader, mut ew_sfx: EventWriter, q_conv: Query<&Chat>, time: Res