From 204c5c160c75c93423e8b3a7d1c324d0ef598abb Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 20 Mar 2024 02:03:42 +0100 Subject: [PATCH] implement sending chat responses --- assets/scenes/conversations.scn.ron | 105 ++++++++++++++++++++++++++-- src/actor.rs | 104 +++++++++++++++++++++++---- src/hud.rs | 89 +++++++++++++++++++++-- src/settings.rs | 35 ++++++++++ 4 files changed, 310 insertions(+), 23 deletions(-) diff --git a/assets/scenes/conversations.scn.ron b/assets/scenes/conversations.scn.ron index 203acd8..510bf15 100644 --- a/assets/scenes/conversations.scn.ron +++ b/assets/scenes/conversations.scn.ron @@ -11,6 +11,7 @@ sound: "ping", level: "info", reply: "Requesting permission to communicate...", + choice: "", goto: "requested", ), }, @@ -25,6 +26,7 @@ sound: "chat", level: "chat", reply: "Oh hey there!", + choice: "", goto: "sup", ), }, @@ -39,6 +41,7 @@ sound: "chat", level: "chat", reply: "Didn't even notice you! Was playing some VR game! What's up?", + choice: "", goto: "reply1", ), }, @@ -49,10 +52,11 @@ id: "hialien", name: "Icarus", label: "reply1", - delay: 3.5, + delay: 5.5, sound: "chat", level: "chat", - reply: "Not so chatty, huh? That's ok. See you around.", + reply: "Are you sure? Your suit is sending a distress call. But whatever you say, have fun!", + choice: "I'm good, how are you?", goto: "pizza", ), }, @@ -62,16 +66,77 @@ "outfly::actor::ChatBranch": ( id: "hialien", name: "Icarus", - label: "pizza", - delay: 1.5, + label: "reply1", + delay: 5.5, sound: "chat", level: "chat", - reply: "Make sure to check out the Pizza place.", - goto: "disco", + reply: "Yeah I can imagine, looks like your suit is leaking. Take care!", + choice: "Uhm... where am I? I don't feel so good.", + goto: "pizza", ), }, ), 4294967301: ( + components: { + "outfly::actor::ChatBranch": ( + id: "hialien", + name: "Icarus", + label: "reply1", + delay: 3.5, + sound: "chat", + level: "chat", + reply: "Not so chatty, huh? That's ok. See you around.", + choice: "", + goto: "pizza", + ), + }, + ), + 4294967302: ( + components: { + "outfly::actor::ChatBranch": ( + id: "hialien", + name: "Icarus", + label: "pizza", + delay: 2.5, + sound: "chat", + level: "chat", + reply: "Make sure to check out the Pizza place.", + choice: "", + goto: "disco_interactive", + ), + }, + ), + 4294967303: ( + components: { + "outfly::actor::ChatBranch": ( + id: "hialien", + name: "Icarus", + label: "disco_interactive", + delay: 0.0, + sound: "ping", + level: "info", + reply: "Disconnected.", + choice: "", + goto: "EXIT", + ), + }, + ), + 4294967304: ( + components: { + "outfly::actor::ChatBranch": ( + id: "hialien", + name: "Icarus", + label: "disco_interactive", + delay: 1.5, + sound: "ping", + level: "chat", + reply: "Bye!", + choice: "See ya~", + goto: "disco", + ), + }, + ), + 4294967305: ( components: { "outfly::actor::ChatBranch": ( id: "hialien", @@ -81,10 +146,30 @@ sound: "ping", level: "info", reply: "Disconnected.", + choice: "", goto: "EXIT", ), }, ), + 4294967306: ( + components: { + "outfly::actor::ChatBranch": ( + id: "hialien", + name: "Icarus", + label: "sup", + delay: 8.0, + sound: "chat", + level: "chat", + reply: "Didn't even notice you! Was playing some VR game! What's up?", + choice: "Uhm... hi", + goto: "reply1", + ), + }, + ), + + + + 4294967400: ( components: { "outfly::actor::ChatBranch": ( @@ -95,6 +180,7 @@ sound: "ping", level: "chat", reply: "Requesting permission to communicate...", + choice: "", goto: "requested", ), }, @@ -109,6 +195,7 @@ sound: "chat", level: "chat", reply: "Welcome to Space Pizza™, best pizza all across the Jovian rings!", + choice: "", goto: "ask", ), }, @@ -123,6 +210,7 @@ sound: "chat", level: "chat", reply: "Would you like to order today's special Miracle Spacefungi? Freshly blended pizza smoothie ready for your space suit feeding tube!", + choice: "", goto: "hello?", ), }, @@ -137,11 +225,13 @@ sound: "chat", level: "chat", reply: "Hello? Are you still there?", + choice: "", + choice_delay: 0.0, goto: "disco", ), }, ), - 4294967304: ( + 4294967404: ( components: { "outfly::actor::ChatBranch": ( id: "pizzeria", @@ -151,6 +241,7 @@ sound: "ping", level: "info", reply: "Disconnected.", + choice: "", goto: "EXIT", ), }, diff --git a/src/actor.rs b/src/actor.rs index 6dd4af8..e285e35 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -9,17 +9,18 @@ impl Plugin for ActorPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup); app.register_type::(); - app.register_type::(); app.add_systems(FixedUpdate, ( update_physics_lifeforms, update_physics_actors, )); app.add_systems(Update, ( handle_new_conversations, + handle_send_messages, handle_conversations, handle_input, )); app.add_event::(); + app.add_event::(); } } @@ -28,6 +29,13 @@ pub struct StartConversationEvent { pub talker: Talker, } +#[derive(Event)] +pub struct SendMessageEvent { + pub conv_id: String, + pub conv_label: String, + pub text: String, +} + #[derive(Component)] pub struct Actor { pub hp: f32, @@ -62,15 +70,7 @@ pub struct ChatBranch { pub level: String, pub reply: String, pub goto: String, -} - -#[derive(Component, Reflect, Default)] -#[reflect(Component)] -pub struct ChatChoice { - pub id: String, - pub label: String, pub choice: String, - pub goto: String, } #[derive(Component)] @@ -202,6 +202,70 @@ pub fn handle_new_conversations( } } +pub fn handle_send_messages( + mut commands: Commands, + mut er_sendmsg: EventReader, + mut ew_sfx: EventWriter, + mut q_conv: Query<(Entity, &mut Chat)>, + time: Res