use bevy::prelude::*;

use crate::resources::AppState;

use super::pause::Pause;

#[derive(Clone, Copy, Debug)]
pub struct PausePlugin;

impl Plugin for PausePlugin {

    fn build(&self, app: &mut App) {
        app
            .add_systems(
                OnEnter(AppState::Paused),
                Pause::load,
            )
            .add_systems(
                OnExit(AppState::Paused),
                Pause::unload,
            )
            .add_systems(
                Update,
                Pause::key_events.run_if(in_state(AppState::Paused))
            )
        ;
    }
}
