diff --git a/src/effects.rs b/src/effects.rs new file mode 100644 index 0000000..c7e3174 --- /dev/null +++ b/src/effects.rs @@ -0,0 +1,92 @@ +use bevy::prelude::*; +use crate::settings; + +pub struct EffectsPlugin; + +impl Plugin for EffectsPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Startup, setup); + app.add_systems(Startup, spawn_effects.after(setup)); + app.add_systems(Update, spawn_effects); + app.add_systems(Update, update_fadeblack); + app.add_event::(); + } +} + +#[derive(Clone)] +pub enum Effects { + FadeIn, +} + +#[derive(Component)] pub struct FadeBlack; +#[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, duration: 4.0 }); + } +} + +pub fn spawn_effects( + mut commands: Commands, + mut er_effect: EventReader, + time: Res