voice no longer hard-coded, bogeydope ordering fix, tripwire ignoring on-ground units

This commit is contained in:
AviiNL
2023-12-27 15:51:15 +01:00
parent e6596f27ad
commit a11402e763
7 changed files with 18 additions and 25 deletions

10
Cargo.lock generated
View File

@@ -501,7 +501,6 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4bc7e09282a82a48d70ade0c4c1154b0fd7882a735a39c66766a5d0f4718ea9" checksum = "e4bc7e09282a82a48d70ade0c4c1154b0fd7882a735a39c66766a5d0f4718ea9"
dependencies = [ dependencies = [
"bevy_dylib",
"bevy_internal", "bevy_internal",
] ]
@@ -677,15 +676,6 @@ dependencies = [
"sysinfo", "sysinfo",
] ]
[[package]]
name = "bevy_dylib"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45b99001eb4837c78d9c63cc8b32fda61ea96b194a2cda54b569aeee69a9853c"
dependencies = [
"bevy_internal",
]
[[package]] [[package]]
name = "bevy_ecs" name = "bevy_ecs"
version = "0.12.1" version = "0.12.1"

View File

@@ -30,7 +30,7 @@ opt-level = 3
[workspace.dependencies] [workspace.dependencies]
bevy = { version = "0.12", features = [ bevy = { version = "0.12", features = [
"dynamic_linking", # "dynamic_linking",
"multi-threaded", "multi-threaded",
"trace", "trace",
] } ] }

View File

@@ -162,7 +162,7 @@ fn listen_srs(
let frequency = radio.frequency; let frequency = radio.frequency;
let id = *id; let id = *id;
let voice = radio.voice; let voice = radio.voice.clone();
let stt_url = stt_url.as_str().to_string(); let stt_url = stt_url.as_str().to_string();
radio.handle = Some(tokio.0.spawn(async move { radio.handle = Some(tokio.0.spawn(async move {
loop { loop {
@@ -520,19 +520,18 @@ fn handle_voice_command(
} }
} }
#[derive(Default, Clone, Copy, Debug, Deserialize, Serialize)] #[derive(Default, Clone, Debug, Deserialize, Serialize)]
pub enum Voice { pub struct Voice(String);
#[default]
David, impl Voice {
Zira, pub fn new(voice: impl Into<String>) -> Self {
Self(voice.into())
}
} }
impl std::fmt::Display for Voice { impl std::fmt::Display for Voice {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { write!(f, "{}", self.0)
Self::David => write!(f, "David"),
Self::Zira => write!(f, "Zira"),
}
} }
} }

View File

@@ -47,11 +47,11 @@ pub fn bogey_dope(
return; return;
}; };
let mut distance: f64 = 0.0; let mut distance: f64 = f64::MAX;
let mut n = (None, None); let mut n = (None, None);
for (n_pos, n_heading) in npc.iter() { for (n_pos, n_heading) in npc.iter() {
let d = p_pos.distance_to_nmi(n_pos); let d = p_pos.distance_to_nmi(n_pos);
if distance < d { if d < distance {
distance = d; distance = d;
n = (Some(n_pos), Some(n_heading)); n = (Some(n_pos), Some(n_heading));
} }

View File

@@ -57,7 +57,7 @@ impl Config {
ChannelConfig { ChannelConfig {
frequency: 251000000, frequency: 251000000,
modulation: Modulation::Am, modulation: Modulation::Am,
voice: Voice::David, voice: Voice::new("David"),
}, },
); );

View File

@@ -67,7 +67,7 @@ fn give_awacs_radio(
commands.entity(ent).insert(Radio::new( commands.entity(ent).insert(Radio::new(
channel.frequency, channel.frequency,
channel.modulation, channel.modulation,
channel.voice, channel.voice.clone(),
)); ));
} }
} }

View File

@@ -45,6 +45,10 @@ fn tripwire(
} }
for (n_id, n_position, n_heading) in npc.iter() { for (n_id, n_position, n_heading) in npc.iter() {
if n_position.angels() == 0 {
// ignore on-ground units
continue;
}
let distance = n_position.distance_to_nmi(p_position); let distance = n_position.distance_to_nmi(p_position);
if distance <= p_tripwire.range && !p_tripwire.reported.contains(n_id) { if distance <= p_tripwire.range && !p_tripwire.reported.contains(n_id) {
p_tripwire.reported.push(*n_id); p_tripwire.reported.push(*n_id);