remove radio when hud is active (mainly to remove all nonfree assets)

This commit is contained in:
yuni 2024-03-28 20:03:40 +01:00
parent 6eb126d4c1
commit 44ec500ce7

View file

@ -7,7 +7,6 @@ const ASSET_SWITCH: &str = "sounds/typosonic-typing-192811-crop.ogg";
const ASSET_INCOMING_MESSAGE: &str = "sounds/connect.ogg"; const ASSET_INCOMING_MESSAGE: &str = "sounds/connect.ogg";
const ASSET_PING: &str = "sounds/connect.ogg"; const ASSET_PING: &str = "sounds/connect.ogg";
const ASSET_CONNECT: &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_BGM: &str = "music/dead-space-style-ambient-music.ogg";
const ASSET_THRUSTER: &str = "sounds/thruster.ogg"; const ASSET_THRUSTER: &str = "sounds/thruster.ogg";
const ASSET_ROCKET: &str = "sounds/rocket.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 PlaySfxEvent(pub Sfx);
#[derive(Event)] pub struct ToggleMusicEvent(); #[derive(Event)] pub struct ToggleMusicEvent();
#[derive(Component)] pub struct ComponentBGM; #[derive(Component)] pub struct ComponentBGM;
#[derive(Component)] pub struct ComponentRadio;
#[derive(Component)] pub struct ComponentThrusterSound; #[derive(Component)] pub struct ComponentThrusterSound;
#[derive(Component)] pub struct ComponentRocketSound; #[derive(Component)] pub struct ComponentRocketSound;
#[derive(Component)] struct SoundBGM(Handle<AudioSource>); #[derive(Component)] struct SoundBGM(Handle<AudioSource>);
#[derive(Component)] pub struct SoundRadio(Handle<AudioSource>);
#[derive(Resource)] pub struct SoundClick(Handle<AudioSource>); #[derive(Resource)] pub struct SoundClick(Handle<AudioSource>);
#[derive(Resource)] pub struct SoundSwitch(Handle<AudioSource>); #[derive(Resource)] pub struct SoundSwitch(Handle<AudioSource>);
#[derive(Resource)] pub struct SoundIncomingMessage(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 { if !settings.mute_sfx {
commands.spawn(( commands.spawn((
AudioBundle { AudioBundle {
@ -183,28 +169,16 @@ pub fn str2sfx(sfx_label: &str) -> Sfx {
pub fn update_music( pub fn update_music(
mut events: EventReader<ToggleMusicEvent>, mut events: EventReader<ToggleMusicEvent>,
bgm_controller: Query<&AudioSink, With<ComponentBGM>>, bgm_controller: Query<&AudioSink, With<ComponentBGM>>,
radio_controller: Query<&AudioSink, With<ComponentRadio>>,
settings: Res<settings::Settings>, settings: Res<settings::Settings>,
) { ) {
if !events.is_empty() { if !events.is_empty() {
events.clear(); events.clear();
if let Ok(bgm_sink) = bgm_controller.get_single() { if let Ok(bgm_sink) = bgm_controller.get_single() {
if let Ok(radio_sink) = radio_controller.get_single() {
if settings.mute_music { if settings.mute_music {
radio_sink.pause();
bgm_sink.pause(); bgm_sink.pause();
} }
else { else {
if settings.hud_active {
radio_sink.play();
bgm_sink.pause();
println!("pausing");
} else {
radio_sink.pause();
bgm_sink.play(); bgm_sink.play();
println!("playing");
}
}
} }
} }
} }