1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use bevy::prelude::*;
use bevy_lunex::UiSystems;
use components::Loading;
use systems::build_loading;

use crate::UiState;

pub mod components;
mod styles;
mod systems;

pub struct LoadingPlugin;

impl Plugin for LoadingPlugin {
    fn build(&self, app: &mut App) {
        app.add_systems(Update, build_loading.before(UiSystems::Compute));
        app.add_systems(
            OnExit(UiState::Loading),
            |mut commands: Commands, load_q: Query<Entity, With<Loading>>| {
                if let Ok(load) = load_q.get_single() {
                    commands.entity(load).despawn_recursive();
                }
            },
        );
    }
}