From b22f780f7352c338dd59a09118005240ca715530 Mon Sep 17 00:00:00 2001 From: hut Date: Sat, 23 Mar 2024 20:13:37 +0100 Subject: [PATCH] implement chat scripts --- src/actor.rs | 45 ++++++++++++++++++++++++++++++++++++++++++++- src/defs.txt | 2 ++ src/world.rs | 10 ++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/actor.rs b/src/actor.rs index e15ee62..a601eaf 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -17,9 +17,11 @@ impl Plugin for ActorPlugin { handle_send_messages, handle_conversations, handle_input, + handle_chat_scripts, )); app.add_event::(); app.add_event::(); + app.add_event::(); } } @@ -35,6 +37,12 @@ pub struct SendMessageEvent { pub text: String, } +#[derive(Event)] +pub struct ChatScriptEvent { + name: String, + param: String, +} + #[derive(Component)] pub struct Actor { pub hp: f32, @@ -74,6 +82,8 @@ pub struct ChatBranch { pub reply: String, pub goto: String, pub choice: String, + pub script: String, + pub script_parameter: String, } #[derive(Component)] @@ -266,6 +276,7 @@ pub fn handle_send_messages( mut commands: Commands, mut er_sendmsg: EventReader, mut ew_sfx: EventWriter, + mut ew_chatscript: EventWriter, mut q_conv: Query<(Entity, &mut Chat)>, time: Res