remove radio when hud is active (mainly to remove all nonfree assets)
This commit is contained in:
parent
6eb126d4c1
commit
44ec500ce7
36
src/audio.rs
36
src/audio.rs
|
@ -7,7 +7,6 @@ const ASSET_SWITCH: &str = "sounds/typosonic-typing-192811-crop.ogg";
|
|||
const ASSET_INCOMING_MESSAGE: &str = "sounds/connect.ogg";
|
||||
const ASSET_PING: &str = "sounds/connect.ogg";
|
||||
const ASSET_CONNECT: &str = "sounds/connect.ogg";
|
||||
const ASSET_RADIO: &str = "external/LP - Girls Go Wild (Official Music Video) [M7XRN0oHGIM].mp3";
|
||||
const ASSET_BGM: &str = "music/dead-space-style-ambient-music.ogg";
|
||||
const ASSET_THRUSTER: &str = "sounds/thruster.ogg";
|
||||
const ASSET_ROCKET: &str = "sounds/rocket.ogg";
|
||||
|
@ -39,11 +38,9 @@ pub enum Sfx {
|
|||
#[derive(Event)] pub struct PlaySfxEvent(pub Sfx);
|
||||
#[derive(Event)] pub struct ToggleMusicEvent();
|
||||
#[derive(Component)] pub struct ComponentBGM;
|
||||
#[derive(Component)] pub struct ComponentRadio;
|
||||
#[derive(Component)] pub struct ComponentThrusterSound;
|
||||
#[derive(Component)] pub struct ComponentRocketSound;
|
||||
#[derive(Component)] struct SoundBGM(Handle<AudioSource>);
|
||||
#[derive(Component)] pub struct SoundRadio(Handle<AudioSource>);
|
||||
#[derive(Resource)] pub struct SoundClick(Handle<AudioSource>);
|
||||
#[derive(Resource)] pub struct SoundSwitch(Handle<AudioSource>);
|
||||
#[derive(Resource)] pub struct SoundIncomingMessage(Handle<AudioSource>);
|
||||
|
@ -67,17 +64,6 @@ pub fn setup(
|
|||
},
|
||||
},
|
||||
));
|
||||
commands.spawn((
|
||||
ComponentRadio,
|
||||
AudioBundle {
|
||||
source: SoundBGM(asset_server.load(ASSET_RADIO)).0.clone(),
|
||||
settings: PlaybackSettings {
|
||||
mode: PlaybackMode::Loop,
|
||||
paused: !settings.hud_active || settings.mute_music,
|
||||
..default()
|
||||
},
|
||||
},
|
||||
));
|
||||
if !settings.mute_sfx {
|
||||
commands.spawn((
|
||||
AudioBundle {
|
||||
|
@ -183,28 +169,16 @@ pub fn str2sfx(sfx_label: &str) -> Sfx {
|
|||
pub fn update_music(
|
||||
mut events: EventReader<ToggleMusicEvent>,
|
||||
bgm_controller: Query<&AudioSink, With<ComponentBGM>>,
|
||||
radio_controller: Query<&AudioSink, With<ComponentRadio>>,
|
||||
settings: Res<settings::Settings>,
|
||||
) {
|
||||
if !events.is_empty() {
|
||||
events.clear();
|
||||
if let Ok(bgm_sink) = bgm_controller.get_single() {
|
||||
if let Ok(radio_sink) = radio_controller.get_single() {
|
||||
if settings.mute_music {
|
||||
radio_sink.pause();
|
||||
bgm_sink.pause();
|
||||
}
|
||||
else {
|
||||
if settings.hud_active {
|
||||
radio_sink.play();
|
||||
bgm_sink.pause();
|
||||
println!("pausing");
|
||||
} else {
|
||||
radio_sink.pause();
|
||||
bgm_sink.play();
|
||||
println!("playing");
|
||||
}
|
||||
}
|
||||
if settings.mute_music {
|
||||
bgm_sink.pause();
|
||||
}
|
||||
else {
|
||||
bgm_sink.play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue