turn settings into a resource
This commit is contained in:
parent
25298b2951
commit
d58e9ebb1e
|
@ -13,7 +13,6 @@ fn main() {
|
|||
App::new()
|
||||
.add_systems(Startup, (
|
||||
setup,
|
||||
settings::setup,
|
||||
audio::setup,
|
||||
player::setup,
|
||||
world::setup,
|
||||
|
@ -33,6 +32,7 @@ fn main() {
|
|||
FrameTimeDiagnosticsPlugin,
|
||||
LogDiagnosticsPlugin::default(),
|
||||
))
|
||||
.insert_resource(settings::Settings::default())
|
||||
.run();
|
||||
}
|
||||
|
||||
|
@ -50,16 +50,13 @@ fn setup(
|
|||
|
||||
fn handle_input(
|
||||
keyboard_input: Res<ButtonInput<KeyCode>>,
|
||||
mut settings: Query<&mut settings::Settings>,
|
||||
mut settings: ResMut<settings::Settings>,
|
||||
mut app_exit_events: ResMut<Events<bevy::app::AppExit>>
|
||||
) {
|
||||
if keyboard_input.pressed(KeyCode::KeyQ) {
|
||||
app_exit_events.send(bevy::app::AppExit);
|
||||
}
|
||||
if keyboard_input.just_pressed(KeyCode::F12) {
|
||||
let result = settings.get_single_mut();
|
||||
if result.is_ok() {
|
||||
result.unwrap().reset()
|
||||
}
|
||||
settings.reset();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use bevy::prelude::*;
|
||||
|
||||
#[derive(Component)]
|
||||
#[derive(Resource)]
|
||||
pub struct Settings {
|
||||
pub mute_sfx: bool,
|
||||
pub mute_music: bool,
|
||||
|
@ -25,7 +25,3 @@ impl Settings {
|
|||
*self = Self::default();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setup(mut commands: Commands) {
|
||||
commands.spawn(Settings::default());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue