generated from tipragot/rust
Change of file structure for scenes #38
|
@ -2,12 +2,10 @@
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use border_wars::scenes::ScenesPlugin;
|
use border_wars::scenes::ScenesPlugin;
|
||||||
use border_wars::CurrentScene;
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins(DefaultPlugins)
|
.add_plugins(DefaultPlugins)
|
||||||
.add_state::<CurrentScene>()
|
|
||||||
.add_plugins(ScenesPlugin)
|
.add_plugins(ScenesPlugin)
|
||||||
.run();
|
.run();
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
|
|||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,7 @@ pub struct MenuPlugin;
|
||||||
|
|
||||||
impl Plugin for MenuPlugin {
|
impl Plugin for MenuPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(
|
app.add_systems(Update, menu_ui.run_if(in_state(CurrentScene::Menu)));
|
||||||
Update,
|
|
||||||
menu_ui.run_if(state_exists_and_equals(CurrentScene::Menu)),
|
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
If the resource is always initialized, there is no need to check for existence. Use in_state instead. If the resource is always initialized, there is no need to check for existence. Use in_state instead.
|
|||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
Change GameState to CurrentScene or Scene Change GameState to CurrentScene or Scene
|
|||||||
/// Display the UI of the menu to host a game or join one.
|
/// Display the UI of the menu to host a game or join one.
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_egui::EguiPlugin;
|
use bevy_egui::EguiPlugin;
|
||||||
|
|
||||||
|
use crate::CurrentScene;
|
||||||
|
|
||||||
pub mod menu;
|
pub mod menu;
|
||||||
|
|
||||||
CoCo_Sol marked this conversation as resolved
Outdated
tipragot
commented
Rename this to ScenePlugin Rename this to ScenePlugin
|
|||||||
/// The plugin for all scenes.
|
/// The plugin for all scenes.
|
||||||
|
@ -10,6 +12,8 @@ pub struct ScenesPlugin;
|
||||||
|
|
||||||
impl Plugin for ScenesPlugin {
|
impl Plugin for ScenesPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue
Add it in the ScenesPlugin instead.