extern crate yaml_rust; use bevy::prelude::*; pub struct ChatPlugin; impl Plugin for ChatPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, load_chats); app.add_event::(); } } #[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: "undefined".to_string(), }}} #[derive(Event)] pub struct StartConversationEvent { pub talker: Talker, } #[derive(Resource)] pub struct ChatDB(Vec); pub fn load_chats( mut commands: Commands, ) { let yaml_strings = [ include_str!("chats/serenity.yaml"), include_str!("chats/startrans.yaml"), ]; let yaml_data = yaml_strings.join("\n\n---\n\n"); if let Ok(yaml_data) = yaml_rust::YamlLoader::load_from_str(yaml_data.as_str()) { commands.insert_resource(ChatDB(yaml_data)); } else { error!("Could not load chat definitions. Validate files in `src/chats/` path."); commands.insert_resource(ChatDB(Vec::new())); } }