diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-02 00:24:00 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-02 00:24:00 +0300 |
| commit | 72eff35e96ea0c9029248d8403c0a37f63642b79 (patch) | |
| tree | 3aeda01bd2ccbe9940e2e6caab44e2435129a13d /crates/fparkan-runtime | |
| parent | 3efc5ba5d3389da168b00f8fe47d3478821e5d7f (diff) | |
| download | fparkan-72eff35e96ea0c9029248d8403c0a37f63642b79.tar.xz fparkan-72eff35e96ea0c9029248d8403c0a37f63642b79.zip | |
feat(ui): animate and sound the original radar sweep
Draw the native 20-segment outline over the cockpit dial and under its contacts. Read the installed radar period and restart only after two periods, playing the configured RADAR cue independently of mission speech. Check the growing and reset sweep on the stock Fireline start.
Diffstat (limited to 'crates/fparkan-runtime')
| -rw-r--r-- | crates/fparkan-runtime/src/radar.rs | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/crates/fparkan-runtime/src/radar.rs b/crates/fparkan-runtime/src/radar.rs index a6cb9f78..677c3348 100644 --- a/crates/fparkan-runtime/src/radar.rs +++ b/crates/fparkan-runtime/src/radar.rs @@ -41,14 +41,30 @@ pub struct CockpitContact { /// The range printed on the cockpit dial, even when the antenna is unpowered. #[must_use] pub fn cockpit_range_readout(engine: &Engine, cockpit: StartingCockpit) -> i32 { - let range = engine.loaded.as_ref().and_then(|mission| { - let table = mission - .control_device_tables - .iter() - .find(|table| table.handle == cockpit.handle)?; - Some(f32::from_bits(radar_device(table)?.coefficient_bits?[3])) - }); - range_readout(range) + range_readout(cockpit_radar_coefficient(engine, cockpit, 3)) +} + +/// The installed radar's period for the HUD sweep, from Control selector 0xa9. +#[must_use] +pub fn cockpit_radar_period(engine: &Engine, cockpit: StartingCockpit) -> Option<f32> { + cockpit_radar_coefficient(engine, cockpit, 4) + .filter(|period| period.is_finite() && *period > 0.0) +} + +fn cockpit_radar_coefficient( + engine: &Engine, + cockpit: StartingCockpit, + index: usize, +) -> Option<f32> { + let table = engine + .loaded + .as_ref()? + .control_device_tables + .iter() + .find(|table| table.handle == cockpit.handle)?; + Some(f32::from_bits( + radar_device(table)?.coefficient_bits?[index], + )) } fn range_readout(range: Option<f32>) -> i32 { |
