diff --git a/assets/sprites/dashboard_leak.png b/assets/sprites/dashboard_leak.png new file mode 100644 index 0000000..771098e Binary files /dev/null and b/assets/sprites/dashboard_leak.png differ diff --git a/src/hud.rs b/src/hud.rs index a2486b9..9a028d4 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -83,8 +83,6 @@ impl Plugin for HudPlugin { #[derive(Component)] struct Reticule; #[derive(Component)] struct Speedometer; #[derive(Component)] struct Speedometer2; -#[derive(Component)] struct Dashboard; -#[derive(Component)] struct DashboardFlashlight; #[derive(Component)] struct GaugeLength(f32); #[derive(Component)] pub struct ToggleableHudElement; #[derive(Component)] pub struct ToggleableHudMapElement; @@ -92,6 +90,12 @@ impl Plugin for HudPlugin { #[derive(Component)] pub struct IsTargeted; #[derive(Component)] pub struct PointOfInterestMarker(pub Entity); +#[derive(Component, Debug, Copy, Clone)] +enum Dashboard { + Leak, + Flashlight, +} + #[derive(Component, Debug, Copy, Clone)] enum Gauge { Health, @@ -362,7 +366,6 @@ fn setup( visibility, ..default() }, - Dashboard, ToggleableHudElement, )).with_children(|builder| { builder.spawn(( @@ -398,7 +401,6 @@ fn setup( visibility, ..default() }, - Dashboard, ToggleableHudElement, )).with_children(|builder| { // The gauge symbol @@ -435,7 +437,11 @@ fn setup( // Car-Dashboard-Style icons let flashlight_visibility = bool2vis(visibility == Visibility::Visible && settings.flashlight_active); - let dashboard_flashlight_handle: Handle = asset_server.load("sprites/dashboard_highbeams.png"); + let style_dashboard = Style { + width: Val::VMin(6.0), + height: Val::VMin(6.0), + ..Default::default() + }; commands.spawn(( NodeBundle { style: Style { @@ -450,21 +456,25 @@ fn setup( visibility, ..default() }, - Dashboard, ToggleableHudElement, )).with_children(|builder| { builder.spawn(( ImageBundle { - image: UiImage::new(dashboard_flashlight_handle), - style: Style { - width: Val::VMin(6.0), - height: Val::VMin(6.0), - ..Default::default() - }, + image: UiImage::new(asset_server.load("sprites/dashboard_highbeams.png")), + style: style_dashboard.clone(), visibility: flashlight_visibility, ..Default::default() }, - DashboardFlashlight, + Dashboard::Flashlight, + )); + builder.spawn(( + ImageBundle { + image: UiImage::new(asset_server.load("sprites/dashboard_leak.png")), + style: style_dashboard.clone(), + visibility: flashlight_visibility, + ..Default::default() + }, + Dashboard::Leak, )); }); @@ -609,14 +619,26 @@ fn setup( fn update_dashboard( timer: ResMut, - mut q_flashlight: Query<&mut Visibility, With>, + mut q_dashboard: Query<(&mut Visibility, &Dashboard)>, + q_player: Query<&actor::Suit, With>, settings: Res, ) { if !settings.hud_active || !timer.0.just_finished() { return; } - for mut vis in &mut q_flashlight { - *vis = bool2vis(settings.flashlight_active); + let player = q_player.get_single(); + if player.is_err() { return; } + let suit = player.unwrap(); + + for (mut vis, icon) in &mut q_dashboard { + *vis = bool2vis(match icon { + Dashboard::Flashlight => { + settings.flashlight_active + } + Dashboard::Leak => { + suit.integrity < 0.5 + } + }); } } diff --git a/src/svg/dashboard_leak.svg b/src/svg/dashboard_leak.svg new file mode 100644 index 0000000..e64b65f --- /dev/null +++ b/src/svg/dashboard_leak.svg @@ -0,0 +1,139 @@ + + + +