use crate::{despawn_screen, AppState}; use bevy::prelude::*; use covey_asset_loader::prelude::*; use std::marker::PhantomData; #[derive(AssetCollection, Debug, Resource, Reflect)] pub(crate) struct SplashAssets { #[asset(path = "fonts/FiraSans-Bold.ttf")] font1: Handle, #[asset(path = "audio/breakout_collision.ogg")] audio1: Handle, #[asset(path = "images/icon.png")] image1: Handle, } pub(crate) struct SplashPlugin; impl Plugin for SplashPlugin { fn build(&self, app: &mut App) { app.insert_resource(SplashTimer(Timer::from_seconds(1.0, TimerMode::Once))) .state_asset_loader::() .cleanup_assets_on_exit::(AppState::Splash) .insert_resource(AssetCleanUpTimer::( Timer::from_seconds(2.0, TimerMode::Once), PhantomData, )) .add_systems(( setup.in_schedule(OnEnter(AppState::Splash)), splash_countdown.in_set(OnUpdate(AppState::Splash)), despawn_screen::.in_schedule(OnExit(AppState::Splash)), read_event, )); } } #[derive(Component)] struct OnSplashScreen; #[derive(Resource, Deref, DerefMut)] struct SplashTimer(Timer); fn setup(mut commands: Commands, assets: Res, audio: Res