// ▄████████▄ + ███ + ▄█████████ ███ + // ███▀ ▀███ + + ███ ███▀ + ███ + + // ███ + ███ ███ ███ █████████ ███ ███ ███ ███ // ███ +███ ███ ███ ███ ███▐██████ ███ ███ ███ // ███ + ███ ███+ ███ +███ ███ + ███ ███ + ███ // ███▄ ▄███ ███▄ ███ ███ + ███ + ███ ███▄ ███ // ▀████████▀ + ▀███████ ███▄ ███▄ ▀████ ▀███████ // + + + ███ // + ▀████████████████████████████████████████████████████▀ // // This module manages visual effects. use crate::prelude::*; use bevy::prelude::*; pub struct VisualPlugin; impl Plugin for VisualPlugin { fn build(&self, app: &mut App) { app.add_systems(Startup, setup.after(menu::setup).after(hud::setup)); app.add_systems( Startup, spawn_effects.after(setup).after(camera::setup_camera), ); app.add_systems(Update, spawn_effects); app.add_systems(Update, update_fadein); app.add_systems(Update, update_fadeout); app.add_systems(Update, play_animations); // Blackout disabled for now //app.add_systems(Update, update_blackout); app.add_event::(); } } #[derive(Clone)] pub enum Effects { FadeIn(Color), FadeOut(Color), } // Blackout disabled for now //#[derive(Component)] pub struct BlackOutOverlay; #[derive(Component)] pub struct FadeIn; #[derive(Component)] pub struct FadeOut; #[derive(Component)] pub struct Effect { pub class: Effects, pub duration: f64, pub start_time: f64, } #[derive(Event)] pub struct SpawnEffectEvent { pub class: Effects, pub duration: f64, } pub fn setup(settings: Res, mut ew_effect: EventWriter) { if !settings.dev_mode { ew_effect.send(SpawnEffectEvent { class: Effects::FadeIn(Color::BLACK), duration: 4.0, }); } // Blackout disabled for now // commands.spawn(( // BlackOutOverlay, // NodeBundle { // style: Style { // width: Val::Vw(100.0), // height: Val::Vh(100.0), // position_type: PositionType::Absolute, // top: Val::Px(0.0), // left: Val::Px(0.0), // ..default() // }, // background_color: Color::BLACK.into(), // ..default() // }, // )); } pub fn spawn_effects( mut commands: Commands, mut er_effect: EventReader, time: Res