use bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer};
use bevy_seedling::prelude::*;
use std::time::Duration;
fn main() {
App::new()
.add_plugins((
MinimalPlugins,
LogPlugin::default(),
AssetPlugin::default(),
SeedlingPlugin::default(),
))
.add_systems(Startup, startup)
.add_systems(Update, remove_pool.run_if(on_timer(Duration::from_secs(5))))
.run();
}
#[derive(PoolLabel, PartialEq, Eq, Debug, Hash, Clone)]
struct AmbiencePool;
fn startup(server: Res<AssetServer>, mut commands: Commands) {
commands.spawn(SamplerPool(AmbiencePool));
commands.spawn((
AmbiencePool,
SamplePlayer::new(server.load("crow_ambience.ogg")).looping(),
));
}
fn remove_pool(mut commands: Commands) {
info_once!("Cleaning up pool...");
commands.despawn_pool(AmbiencePool);
}