Change init of state ressource
All checks were successful
Rust Checks / checks (push) Successful in 1m1s
Rust Checks / checks (pull_request) Successful in 1m0s

This commit is contained in:
CoCo_Sol 2024-02-10 18:17:27 +01:00
parent 55440c9700
commit b025b6d9d3
3 changed files with 6 additions and 7 deletions

View file

@ -2,12 +2,10 @@
use bevy::prelude::*;
use border_wars::scenes::ScenesPlugin;
use border_wars::CurrentScene;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_state::<CurrentScene>()
.add_plugins(ScenesPlugin)
.run();
}

View file

@ -10,10 +10,7 @@ pub struct MenuPlugin;
impl Plugin for MenuPlugin {
fn build(&self, app: &mut App) {
app.add_systems(
Update,
menu_ui.run_if(state_exists_and_equals(CurrentScene::Menu)),
);
app.add_systems(Update, menu_ui.run_if(in_state(CurrentScene::Menu)));
}
}
/// Display the UI of the menu to host a game or join one.

View file

@ -3,6 +3,8 @@
use bevy::prelude::*;
use bevy_egui::EguiPlugin;
use crate::CurrentScene;
pub mod menu;
/// The plugin for all scenes.
@ -10,6 +12,8 @@ pub struct ScenesPlugin;
impl Plugin for ScenesPlugin {
fn build(&self, app: &mut App) {
app.add_plugins(EguiPlugin).add_plugins(menu::MenuPlugin);
app.add_plugins(EguiPlugin)
.add_state::<CurrentScene>()
.add_plugins(menu::MenuPlugin);
}
}