omg so much has changed idk
This commit is contained in:
@@ -74,7 +74,7 @@ impl Braa {
|
||||
let bearing = split(&self.bearing.to_string(), 1);
|
||||
let range = split(&self.range.to_string(), 1);
|
||||
format!(
|
||||
"BRA <break time=\"250ms\"/> {} <break /> {} <break /> {} thousand <break /> {}",
|
||||
"BRA . . . {} . . . {} . . . {} thousand . . . {}",
|
||||
bearing, range, self.angels, self.aspect
|
||||
)
|
||||
}
|
||||
|
||||
@@ -64,13 +64,13 @@ pub fn bogey_dope(
|
||||
let (Some(n_position), Some(n_heading)) = n else {
|
||||
let message = format!("{}, {}, {}", p_callsign, a_callsign, "Skies are clear");
|
||||
let voice_message = format!(
|
||||
"{}, {}, {}",
|
||||
"{} . . . {} . . . {}",
|
||||
p_callsign.to_voice(),
|
||||
a_callsign.to_voice(),
|
||||
"Skies are clear"
|
||||
);
|
||||
|
||||
commands.spawn(TextMessage::new(message));
|
||||
commands.entity(*pilot).insert(TextMessage::new(message));
|
||||
commands
|
||||
.entity(*operator)
|
||||
.insert(VoiceMessage::new(voice_message));
|
||||
@@ -80,13 +80,13 @@ pub fn bogey_dope(
|
||||
let bra = Braa::new(p_pos, n_position, n_heading);
|
||||
let message = format!("{}, {}, {}", p_callsign, a_callsign, bra);
|
||||
let voice_message = format!(
|
||||
"{}, {}, {}",
|
||||
"{} . . . {} . . . {}",
|
||||
p_callsign.to_voice(),
|
||||
a_callsign.to_voice(),
|
||||
bra.to_voice()
|
||||
);
|
||||
|
||||
commands.spawn(TextMessage::new(message));
|
||||
commands.entity(*pilot).insert(TextMessage::new(message));
|
||||
commands
|
||||
.entity(*operator)
|
||||
.insert(VoiceMessage::new(voice_message));
|
||||
|
||||
@@ -53,7 +53,7 @@ pub fn clear_tripwire(
|
||||
a_callsign.to_voice(),
|
||||
);
|
||||
|
||||
commands.spawn(TextMessage::new(message));
|
||||
commands.entity(*pilot).insert(TextMessage::new(message));
|
||||
commands
|
||||
.entity(*operator)
|
||||
.insert(VoiceMessage::new(message_voice));
|
||||
|
||||
@@ -44,13 +44,13 @@ pub fn radio_check(
|
||||
|
||||
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(*pilot).insert(TextMessage::new(message));
|
||||
commands
|
||||
.entity(*operator)
|
||||
.insert(VoiceMessage::new(voice_message));
|
||||
|
||||
@@ -96,7 +96,7 @@ pub fn set_tripwire(
|
||||
distance
|
||||
);
|
||||
|
||||
commands.spawn(TextMessage::new(message));
|
||||
commands.entity(*pilot).insert(TextMessage::new(message));
|
||||
commands
|
||||
.entity(*operator)
|
||||
.insert(VoiceMessage::new(message_voice));
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::{collections::HashMap, path::PathBuf};
|
||||
use bevy::ecs::system::Resource;
|
||||
use guardian_core::{
|
||||
components::{GrpcBaseUrl, SrsSocketAddr, SttBaseUrl},
|
||||
srs::{Modulation as SrsModulation, Voice},
|
||||
srs::Modulation as SrsModulation,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -27,7 +27,6 @@ pub struct SrsConfig {
|
||||
pub struct ChannelConfig {
|
||||
pub frequency: u64,
|
||||
pub modulation: Modulation, // 0=AM, 1=FM?
|
||||
pub voice: Voice,
|
||||
}
|
||||
|
||||
impl TryFrom<PathBuf> for Config {
|
||||
@@ -57,7 +56,6 @@ impl Config {
|
||||
ChannelConfig {
|
||||
frequency: 251000000,
|
||||
modulation: Modulation::Am,
|
||||
voice: Voice::new("David"),
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
44
src/main.rs
44
src/main.rs
@@ -3,6 +3,8 @@ mod commands;
|
||||
mod config;
|
||||
mod tripwire;
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use bevy::{
|
||||
app::{App, Update},
|
||||
ecs::{
|
||||
@@ -11,6 +13,7 @@ use bevy::{
|
||||
system::{Commands, Query, Res},
|
||||
},
|
||||
};
|
||||
use clap::Parser;
|
||||
use commands::CommandsPlugin;
|
||||
use config::{Channels, Config};
|
||||
use guardian_core::{
|
||||
@@ -19,8 +22,15 @@ use guardian_core::{
|
||||
DefaultPlugins, TokioResource,
|
||||
};
|
||||
use tokio::runtime::Handle;
|
||||
use tracing::info;
|
||||
use tripwire::TripwirePlugin;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
struct CommandLineArguments {
|
||||
#[arg(short, long)]
|
||||
config: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
let subscriber = tracing_subscriber::FmtSubscriber::builder()
|
||||
@@ -35,7 +45,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
|
||||
tracing::subscriber::set_global_default(subscriber)?;
|
||||
|
||||
let config = Config::load("config.toml".into())?;
|
||||
let args = CommandLineArguments::parse();
|
||||
|
||||
let config = match args.config {
|
||||
Some(c) => {
|
||||
if !c.try_exists()? {
|
||||
return Err(format!("Config file {} not found", c.display()).into());
|
||||
}
|
||||
c
|
||||
}
|
||||
None => "config.toml".into(),
|
||||
};
|
||||
|
||||
info!("Loading config {}", config.display());
|
||||
|
||||
let config = Config::load(config)?;
|
||||
|
||||
App::new()
|
||||
.insert_resource(config.srs.server)
|
||||
@@ -64,20 +88,8 @@ fn give_awacs_radio(
|
||||
|
||||
bevy::log::info!("{} now has a radio", callsign);
|
||||
|
||||
commands.entity(ent).insert(Radio::new(
|
||||
channel.frequency,
|
||||
channel.modulation,
|
||||
channel.voice.clone(),
|
||||
));
|
||||
commands
|
||||
.entity(ent)
|
||||
.insert(Radio::new(channel.frequency, channel.modulation));
|
||||
}
|
||||
}
|
||||
|
||||
// // Initial player tripwire? get from some db so player doesnt need to redo it everytime
|
||||
// fn add_tripwire(mut commands: Commands, players: Query<Entity, Added<Player>>) {
|
||||
// for ent in players.iter() {
|
||||
// commands.entity(ent).insert(Tripwire {
|
||||
// range: 2.0,
|
||||
// reported: vec![],
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -26,7 +26,7 @@ impl Plugin for TripwirePlugin {
|
||||
fn tripwire(
|
||||
mut commands: Commands,
|
||||
awacs: Query<(Entity, &Callsign, &Radio), (With<Awacs>, With<Blue>, With<Radio>)>,
|
||||
mut players: Query<(&Callsign, &Position, &RadioInfo, &mut Tripwire), With<Player>>,
|
||||
mut players: Query<(Entity, &Callsign, &Position, &RadioInfo, &mut Tripwire), With<Player>>,
|
||||
npc: Query<(&Id, &Position, &Heading, &Velocity), (Without<Player>, With<Red>)>,
|
||||
) {
|
||||
// get the players radio frequencies
|
||||
@@ -34,7 +34,7 @@ fn tripwire(
|
||||
// broadcast message on that ferquency and as that awacs
|
||||
|
||||
for (ent, awacs, radio) in awacs.iter() {
|
||||
for (p_callsign, p_position, radioinfo, mut p_tripwire) in players.iter_mut() {
|
||||
for (p_ent, p_callsign, p_position, radioinfo, mut p_tripwire) in players.iter_mut() {
|
||||
// check if user is on the same frequency as awacs
|
||||
if !radioinfo
|
||||
.radios
|
||||
@@ -56,13 +56,14 @@ fn tripwire(
|
||||
let bra = Braa::new(p_position, n_position, n_heading);
|
||||
let message = format!("{}, {}, {}", p_callsign, awacs, bra);
|
||||
let voice_message = format!(
|
||||
"{}, {}, {}",
|
||||
"{} . . . {} . . . {}",
|
||||
p_callsign.to_voice(),
|
||||
awacs.to_voice(),
|
||||
bra.to_voice()
|
||||
);
|
||||
|
||||
commands.spawn(TextMessage::new(message));
|
||||
// commands.spawn((Id::new(player_id.into()), TextMessage::new(message)));
|
||||
commands.entity(p_ent).insert(TextMessage::new(message));
|
||||
commands
|
||||
.entity(ent)
|
||||
.insert(VoiceMessage::new(voice_message));
|
||||
|
||||
Reference in New Issue
Block a user