Yikes, make example compile again.

This commit is contained in:
Nolan Darilek 2021-05-21 12:02:07 -05:00
parent eaa2807741
commit ca7492583a

View File

@ -1,5 +1,5 @@
use bevy::{asset::LoadState, prelude::*}; use bevy::{asset::LoadState, prelude::*};
use bevy_openal::{efx, Context, GlobalEffects, Listener, OpenAlPlugin, Sound, Sounds}; use bevy_openal::{efx, Context, GlobalEffects, Listener, OpenAlPlugin, Sound, SoundState};
#[derive(Default)] #[derive(Default)]
struct AssetHandles { struct AssetHandles {
@ -23,8 +23,8 @@ fn setup(
} }
} }
fn load_and_create_system( fn load_and_create(
commands: &mut Commands, mut commands: Commands,
asset_server: Res<AssetServer>, asset_server: Res<AssetServer>,
mut handles: ResMut<AssetHandles>, mut handles: ResMut<AssetHandles>,
) { ) {
@ -35,31 +35,29 @@ fn load_and_create_system(
.get_group_load_state(handles.sounds.iter().map(|handle| handle.id)) .get_group_load_state(handles.sounds.iter().map(|handle| handle.id))
== LoadState::Loaded; == LoadState::Loaded;
if handles.loaded { if handles.loaded {
commands.spawn((Listener::default(), Transform::default)); commands.spawn().insert(Listener).insert(Transform::default);
let handle = handles.sounds[0].clone(); let handle = handles.sounds[0].clone();
let buffer = asset_server.get_handle(handle); let buffer = asset_server.get_handle(handle);
let mut sounds = Sounds::default(); commands
sounds.insert( .spawn()
"footstep".into(), .insert(Transform::from_translation(Vec3::new(15., 0., 0.)))
Sound { .insert(Sound {
buffer, buffer,
autoplay: true, state: SoundState::Playing,
gain: 0.4, gain: 0.4,
looping: true, looping: true,
..Default::default() ..Default::default()
}, });
);
commands.spawn((Transform::from_translation(Vec3::new(15., 0., 0.)), sounds));
} }
} }
fn main() { fn main() {
App::build() App::build()
.add_plugins(DefaultPlugins) .add_plugins(DefaultPlugins)
.add_system(bevy::input::system::exit_on_esc_system) .add_system(bevy::input::system::exit_on_esc_system.system())
.add_plugin(OpenAlPlugin) .add_plugin(OpenAlPlugin)
.init_resource::<AssetHandles>() .init_resource::<AssetHandles>()
.add_startup_system(setup) .add_startup_system(setup.system())
.add_system(load_and_create_system) .add_system(load_and_create.system())
.run(); .run();
} }