diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-03 17:29:21 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-03 17:29:21 +0300 |
| commit | c85b69296f5349a728e28e308c7d71b367dc6ac1 (patch) | |
| tree | 1cf61b85a3763d4a5264f1dd513859630218a936 /apps/fparkan-game/src/cockpit_status_hud.rs | |
| parent | 1776dd8007169ef4f04969f0a5edcc423b6d67bc (diff) | |
| download | fparkan-c85b69296f5349a728e28e308c7d71b367dc6ac1.tar.xz fparkan-c85b69296f5349a728e28e308c7d71b367dc6ac1.zip | |
feat(render): add cockpit infrared lighting
Diffstat (limited to 'apps/fparkan-game/src/cockpit_status_hud.rs')
| -rw-r--r-- | apps/fparkan-game/src/cockpit_status_hud.rs | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/apps/fparkan-game/src/cockpit_status_hud.rs b/apps/fparkan-game/src/cockpit_status_hud.rs index 440622af..b263414b 100644 --- a/apps/fparkan-game/src/cockpit_status_hud.rs +++ b/apps/fparkan-game/src/cockpit_status_hud.rs @@ -49,10 +49,15 @@ impl Lamp { } } -fn lamps(state: CockpitIndicators, risk_since: Option<u32>, clock_ms: u32) -> [Lamp; 8] { +fn lamps( + state: CockpitIndicators, + infrared: bool, + risk_since: Option<u32>, + clock_ms: u32, +) -> [Lamp; 8] { let mut lamps = [Lamp::Off; 8]; lamps[0] = Lamp::from_active(state.self_repair); - // Slot 1 follows the infrared camera pass when that pass is available. + lamps[1] = Lamp::from_active(infrared); lamps[2] = Lamp::from_active(state.camouflage); lamps[3] = Lamp::from_active(state.onsite); if risk_since.is_some_and(|start| clock_ms.wrapping_sub(start) <= 3_000) { @@ -114,6 +119,7 @@ impl CockpitStatusHud { renderer: &mut VulkanSmokeRenderer, mesh: &mut VulkanStaticMesh, state: Option<CockpitIndicators>, + infrared: bool, clock_ms: u32, ) -> Result<(), String> { for (range, count) in self.ranges().into_iter().zip([48, 42, 6]) { @@ -122,7 +128,7 @@ impl CockpitStatusHud { .map_err(|error| error.to_string())?; } let Some(state) = state else { return Ok(()) }; - let lamps = lamps(state, self.risk_since, clock_ms); + let lamps = lamps(state, infrared, self.risk_since, clock_ms); for (index, lamp) in lamps.into_iter().enumerate() { let x = FRAME_X[index]; let start = self.frames.vertex_start + index * 4; @@ -185,10 +191,10 @@ mod tests { control: RemoteWarbotControl::AutoGunner, }; assert_eq!( - lamps(state, Some(100), 3_100), + lamps(state, true, Some(100), 3_100), [ Lamp::On, - Lamp::Off, + Lamp::On, Lamp::Off, Lamp::Off, Lamp::Red, @@ -197,6 +203,9 @@ mod tests { Lamp::Off ], ); - assert_eq!(lamps(state, Some(100), 3_101)[DANGER_INDEX], Lamp::Off); + assert_eq!( + lamps(state, false, Some(100), 3_101)[DANGER_INDEX], + Lamp::Off + ); } } |
