Newer
Older
#![allow(clippy::type_complexity)]
use bevy_app::{App, Plugin, Update};
use bevy_ecs::prelude::*;
pub use crate::components::SplashSettings;
use crate::components::{SplashTime, TweenClearColor};
mod components;
mod system;
#[derive(Default, Debug, Resource)]
struct SplashManager {
}
#[derive(PartialOrd, PartialEq, Copy, Clone, Resource, Default)]
pub enum SplashState {
pub fn is_loading(&self) -> bool {
matches!(&self, SplashState::Loading)
}
pub fn is_running(&self) -> bool {
matches!(&self, SplashState::Running)
}
}
pub fn is_loading(state: Res<SplashState>) -> bool {
}
pub fn is_running(state: Res<SplashState>) -> bool {
}
pub fn started_running(state: Res<SplashState>) -> bool {
impl<StateType: States> MicroSplashPlugin<StateType> {
pub fn with_settings(settings: SplashSettings<StateType>) -> MicroSplashPlugin<StateType> {
impl<StateType: States + Copy> Plugin for MicroSplashPlugin<StateType> {
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
fn build(&self, app: &mut App) {
app.init_resource::<SplashState>()
.insert_resource(SplashTime(Duration::from_secs(5)))
.insert_resource(self.settings.clone())
.add_systems(
OnEnter(self.settings.run_in),
system::load_assets::<StateType>,
)
.add_systems(
Update,
system::monitor_asset_loading
.run_if(is_loading)
.run_if(in_state(self.settings.run_in)),
)
.add_systems(
Update,
system::spawn_splash_assets::<StateType>
.run_if(started_running)
.run_if(in_state(self.settings.run_in)),
)
.add_systems(
Update,
(system::apply_window_scale, system::tick_time::<StateType>)
.run_if(is_running)
.run_if(in_state(self.settings.run_in)),
)
.add_systems(
Update,
system::tween_clear_color
.run_if(is_running)
.run_if(in_state(self.settings.run_in))
.run_if(resource_exists::<TweenClearColor>),
)
.add_systems(OnExit(self.settings.run_in), system::cleanup_assets);
if self.settings.skip_on_input {
app.add_systems(
Update,
system::window_skip::<StateType>
.run_if(is_running)
.run_if(in_state(self.settings.run_in)),
);
}
}