implemented Phone Call and "script changename" command
This commit is contained in:
parent
242e06ebf1
commit
55426ba0dd
18
src/chat.rs
18
src/chat.rs
|
@ -21,6 +21,7 @@ use std::collections::HashMap;
|
|||
|
||||
pub const CHATS: &[&str] = &[
|
||||
include_str!("chats/fastravel.yaml"),
|
||||
include_str!("chats/phone.yaml"),
|
||||
include_str!("chats/serenity.yaml"),
|
||||
include_str!("chats/thebe.yaml"),
|
||||
];
|
||||
|
@ -890,6 +891,7 @@ pub fn handle_chat_scripts(
|
|||
With<actor::Player>,
|
||||
>,
|
||||
mut q_playercam: Query<(&mut Position, &mut LinearVelocity), With<actor::PlayerCamera>>,
|
||||
mut q_chats: Query<&mut Chat>,
|
||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||
mut ew_effect: EventWriter<visual::SpawnEffectEvent>,
|
||||
mut ew_achievement: EventWriter<game::AchievementEvent>,
|
||||
|
@ -1002,6 +1004,22 @@ pub fn handle_chat_scripts(
|
|||
ew_sfx.send(audio::PlaySfxEvent(audio::Sfx::Drink));
|
||||
ew_achievement.send(game::AchievementEvent::DrinkPizza);
|
||||
}
|
||||
"changename" => {
|
||||
let mut new_name = param1.to_string();
|
||||
if !param2.is_empty() {
|
||||
if !new_name.is_empty() {
|
||||
new_name += " ";
|
||||
}
|
||||
new_name += param2;
|
||||
}
|
||||
for mut chat in &mut q_chats {
|
||||
if new_name.is_empty() {
|
||||
chat.talker.name = None;
|
||||
} else {
|
||||
chat.talker.name = Some(new_name.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
error!("Error, undefined chat script {name}");
|
||||
}
|
||||
|
|
10
src/chats/phone.yaml
Normal file
10
src/chats/phone.yaml
Normal file
|
@ -0,0 +1,10 @@
|
|||
- chat: phone
|
||||
- Select contact to call.
|
||||
- FASTravel:
|
||||
- script: changename FASTravel™ Chatbot
|
||||
- This is FASTravel, how can I help you?
|
||||
- Icarus:
|
||||
- script: changename Icarus
|
||||
- Well hi there!
|
||||
- "[Cancel]":
|
||||
- goto: EXIT
|
15
src/game.rs
15
src/game.rs
|
@ -98,6 +98,7 @@ pub enum GameEvent {
|
|||
SetShadows(Turn),
|
||||
UpdateFlashlight,
|
||||
Achievement(String),
|
||||
PhoneCall,
|
||||
}
|
||||
|
||||
pub enum Turn {
|
||||
|
@ -162,6 +163,7 @@ pub fn setup(mut settings: ResMut<Settings>, prefs: ResMut<var::Preferences>) {
|
|||
pub fn handle_game_event(
|
||||
mut settings: ResMut<Settings>,
|
||||
mut er_game: EventReader<GameEvent>,
|
||||
mut ew_conv: EventWriter<chat::StartConversationEvent>,
|
||||
mut ew_sfx: EventWriter<audio::PlaySfxEvent>,
|
||||
mut ew_updateoverlays: EventWriter<hud::UpdateOverlayVisibility>,
|
||||
mut ew_updatemenu: EventWriter<menu::UpdateMenuEvent>,
|
||||
|
@ -270,6 +272,19 @@ pub fn handle_game_event(
|
|||
spotlight.intensity = actor::FLASHLIGHT_INTENSITY[prefs.flashlight_power];
|
||||
}
|
||||
}
|
||||
GameEvent::PhoneCall => {
|
||||
let talker = chat::Talker {
|
||||
chat_name: "phone".to_string(),
|
||||
actor_id: "".to_string(),
|
||||
name: Some("Phone".to_string()),
|
||||
counts_towards_achievement: false,
|
||||
pronoun: None,
|
||||
talking_speed: 0.0,
|
||||
};
|
||||
ew_conv.send(chat::StartConversationEvent {
|
||||
talker: talker,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@ pub enum DeathScreenEvent {
|
|||
}
|
||||
|
||||
pub const MENUDEF: &[(&str, MenuAction)] = &[
|
||||
("Phone Call", MenuAction::PhoneCall),
|
||||
("", MenuAction::ToggleAR),
|
||||
("", MenuAction::ChangeARAvatar),
|
||||
("", MenuAction::ChangePointer),
|
||||
|
@ -92,6 +93,7 @@ pub enum MenuAction {
|
|||
ModReactor,
|
||||
ToggleSound,
|
||||
ToggleMusic,
|
||||
PhoneCall,
|
||||
ToggleCamera,
|
||||
ToggleFullscreen,
|
||||
ToggleShadows,
|
||||
|
@ -713,6 +715,11 @@ pub fn handle_input(
|
|||
ew_game.send(GameEvent::SetShadows(Toggle));
|
||||
ew_updatemenu.send(UpdateMenuEvent);
|
||||
}
|
||||
MenuAction::PhoneCall => {
|
||||
ew_game.send(GameEvent::PhoneCall);
|
||||
ew_game.send(GameEvent::SetMenu(Turn::Off));
|
||||
ew_updatemenu.send(UpdateMenuEvent);
|
||||
}
|
||||
MenuAction::Restart => {
|
||||
settings.god_mode = false;
|
||||
ew_playerdies.send(game::PlayerDiesEvent(actor::DamageType::Depressurization));
|
||||
|
|
Loading…
Reference in a new issue