52 lines
1.2 KiB
Rust
52 lines
1.2 KiB
Rust
use bevy::ecs::system::{Commands, Query, Resource};
|
|
use clap::Parser;
|
|
use guardian_commands::{ConsoleCommand, NamedCommand};
|
|
use guardian_core::{components::*, dcs::text::TextMessage, srs::voice::VoiceMessage};
|
|
|
|
#[derive(Parser, Debug)]
|
|
pub struct RadioCheck;
|
|
|
|
impl NamedCommand for RadioCheck {
|
|
fn name() -> &'static str {
|
|
"radio check"
|
|
}
|
|
}
|
|
|
|
impl Resource for RadioCheck {}
|
|
|
|
pub fn radio_check(
|
|
mut commands: Commands,
|
|
cmd: ConsoleCommand<RadioCheck>,
|
|
callsign: Query<&Callsign>,
|
|
) {
|
|
let Some(pilot) = &cmd.pilot else {
|
|
return; // no pilot
|
|
};
|
|
let Some(operator) = &cmd.operator else {
|
|
return;
|
|
};
|
|
|
|
let Ok(p_callsign) = callsign.get(*pilot) else {
|
|
eprintln!("no player, died?");
|
|
return;
|
|
};
|
|
|
|
let Ok(a_callsign) = callsign.get(*operator) else {
|
|
eprintln!("no awacs, they died?");
|
|
return;
|
|
};
|
|
|
|
let message = format!("{}, {}, {}", p_callsign, a_callsign, "five by five");
|
|
let voice_message = format!(
|
|
"{}, {}, {}",
|
|
p_callsign.to_voice(),
|
|
a_callsign.to_voice(),
|
|
"five by five"
|
|
);
|
|
|
|
commands.spawn(TextMessage::new(message));
|
|
commands
|
|
.entity(*operator)
|
|
.insert(VoiceMessage::new(voice_message));
|
|
}
|