766b292aec
build / mod (push) Successful in 3m51s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
1.6 KiB
Rust
41 lines
1.6 KiB
Rust
//! What the simulation tells the engine sources (`crate::engines`): which sound an entity's
|
|
//! engine makes, from the specs the rest of the simulation owns.
|
|
use super::{DroneKind, MissileKind};
|
|
|
|
impl DroneKind {
|
|
/// The sound of its engine and its pitch; none for the ballistic ones, which fall with a
|
|
/// scream played once (and the Oreshnik's blocks and submunitions, which have no engine).
|
|
pub fn engine_voice(self) -> Option<(&'static str, f32)> {
|
|
let spec = self.spec();
|
|
if spec.ballistic.is_some() || matches!(self, DroneKind::OreshnikBlock | DroneKind::OreshnikSub) {
|
|
return None;
|
|
}
|
|
Some((spec.sound.0, spec.sound.1))
|
|
}
|
|
}
|
|
|
|
impl MissileKind {
|
|
/// The sound of its motor, its gain and its pitch: a rocket's roar, or the electric whine of
|
|
/// a motor without a flame.
|
|
pub fn engine_voice(self) -> (&'static str, f32, f32) {
|
|
if self.spec().flame == 0.0 {
|
|
return ("airdef:drone.lancet", 0.8, 1.6);
|
|
}
|
|
let pitch = match self {
|
|
MissileKind::Pac3 => 1.0,
|
|
MissileKind::M57e6 => 1.12,
|
|
MissileKind::M48n6 => 0.88,
|
|
MissileKind::M77n6 => 0.8,
|
|
MissileKind::IrisT | MissileKind::Amraam => 1.05,
|
|
MissileKind::M9m317 => 0.9,
|
|
MissileKind::M9m338 => 1.15,
|
|
MissileKind::P1sun => 1.7,
|
|
};
|
|
("airdef:missile.flight", 1.0, pitch)
|
|
}
|
|
/// Ticks from the launch until the motor lights (a cold launch throws it out of the tube first).
|
|
pub fn lit_after(self) -> u32 {
|
|
self.spec().cold
|
|
}
|
|
}
|