39 lines
1.0 KiB
Rust
39 lines
1.0 KiB
Rust
use bevy::prelude::*;
|
|
|
|
use crate::states::{
|
|
game::GameState,
|
|
menu::{MainMenuSystems, MenuCleanupSystems, MenuStartupSystems, MenuState},
|
|
play::PlayState,
|
|
};
|
|
|
|
pub struct MainMenuPlugin;
|
|
|
|
impl Plugin for MainMenuPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app.add_systems(Update, spawn_menu.in_set(MenuStartupSystems));
|
|
app.add_systems(Update, clean_menu.in_set(MenuCleanupSystems));
|
|
app.add_systems(Update, main_menu.in_set(MainMenuSystems));
|
|
}
|
|
}
|
|
|
|
fn spawn_menu(mut next: ResMut<NextState<MenuState>>) {
|
|
next.set(MenuState::Main);
|
|
info_once!("Moving to MenuState:{:?}", MenuState::Main);
|
|
}
|
|
|
|
fn clean_menu(mut next: ResMut<NextState<MenuState>>) {
|
|
next.set(MenuState::Idle);
|
|
info_once!("Moving to MenuState:{:?}", MenuState::Loading);
|
|
}
|
|
|
|
fn main_menu(
|
|
mut next_menu: ResMut<NextState<MenuState>>,
|
|
mut next_game: ResMut<NextState<GameState>>,
|
|
mut next_play_state: ResMut<NextState<PlayState>>,
|
|
) {
|
|
next_menu.set(MenuState::Cleanup);
|
|
next_game.set(GameState::InGame);
|
|
next_play_state.set(PlayState::Loading);
|
|
info_once!("Moving to InGame");
|
|
}
|