Compare commits

...

2 commits

Author SHA1 Message Date
yuni a2423fa642 implement sfx volume controls 2024-10-03 23:59:15 +02:00
yuni 09115f8e3c add proper colliders to metis/amalthea/adrastea 2024-10-03 22:59:59 +02:00
5 changed files with 34 additions and 21 deletions

View file

@ -227,7 +227,7 @@ pub fn play_sfx(
if let Some(source) = sounds.0.get(&sfx.0) {
commands.spawn(AudioBundle {
source: source.clone(),
settings: PlaybackSettings::DESPAWN,
settings: PlaybackSettings::DESPAWN.with_volume(Volume::new(settings.volume_sfx)),
});
}
}
@ -278,11 +278,7 @@ pub fn play_gasp_sfx(
continue;
}
if suit.oxygen <= 0.0 && !settings.god_mode {
if settings.mute_sfx {
sink.set_volume(0.0);
} else {
sink.set_volume(0.6);
}
sink.set_volume(settings.volume_sfx * 0.6);
sink.play();
} else {
if !sink.is_paused() {

View file

@ -672,7 +672,9 @@ pub fn apply_input_to_player(
let speed = sink.speed();
let action = pitch_yaw_rot.length_squared().powf(0.2) * 0.0005;
if play_reactionwheel_sound && !settings.mute_sfx && bike.is_some() {
sink.set_volume(reactionwheel_volume * (volume + action).clamp(0.0, 1.0));
sink.set_volume(
settings.volume_sfx * reactionwheel_volume * (volume + action).clamp(0.0, 1.0),
);
sink.set_speed((speed + action * 0.2).clamp(0.2, 0.5));
sink.play()
} else {
@ -706,22 +708,21 @@ pub fn apply_input_to_player(
sink.pause();
} else {
let volume = sink.volume();
let maxvol = settings.volume_sfx * vol_boost;
if engine.engine_type == engine_type {
if play_thruster_sound {
sink.set_speed(speed);
sink.play();
if volume < 1.0 {
let maxvol = vol_boost;
//let maxvol = engine.current_warmup * vol_boost;
if volume < maxvol {
sink.set_volume(
(volume + dt / seconds_to_max_vol).clamp(0.0, maxvol),
);
}
} else {
sink.set_volume((volume - dt / seconds_to_min_vol).clamp(0.0, 1.0));
sink.set_volume((volume - dt / seconds_to_min_vol).clamp(0.0, maxvol));
}
} else if volume > 0.0 {
sink.set_volume((volume - dt / seconds_to_min_vol).clamp(0.0, 1.0));
sink.set_volume((volume - dt / seconds_to_min_vol).clamp(0.0, maxvol));
}
if volume < 0.0001 {
sink.pause();

View file

@ -88,6 +88,7 @@ actor 0 0 0
tidally locked
scale 21.5e3
moon yes
collider handcrafted
angularmomentum 0 0 0
actor 0 0 0 orbitring
relativeto jupiter
@ -103,6 +104,7 @@ actor 0 0 0
tidally locked
scale 8.2e3
moon yes
collider handcrafted
angularmomentum 0 0 0
actor 0 0 0 orbitring
relativeto jupiter
@ -118,6 +120,7 @@ actor 0 0 0
tidally locked
scale 83.5e3
moon yes
collider handcrafted
angularmomentum 0 0 0
actor 0 0 0 orbitring
relativeto jupiter

View file

@ -471,9 +471,9 @@ pub fn update_menu(
.noise_cancellation_modes
.get(settings.noise_cancellation_mode)
{
noisecancel
&noisecancel.0
} else {
&settings.noise_cancellation_modes[0]
&settings.noise_cancellation_modes[0].0
};
text.sections[i].value = format!("\nNoise Cancellation: {noisecancel}\n");
}

View file

@ -41,11 +41,11 @@ pub struct Settings {
pub alive: bool,
pub mute_sfx: bool,
pub noise_cancellation_mode: usize,
pub noise_cancellation_modes: Vec<String>,
pub noise_cancellation_modes: Vec<(String, f32)>,
pub radio_mode: usize,
pub radio_modes: Vec<String>, // see also: settings.is_radio_playing()
pub volume_sfx: u8,
pub volume_music: u8,
pub volume_sfx: f32,
pub volume_music: f32,
pub mouse_sensitivity: f32,
pub fov: f32,
pub fov_highspeed: f32,
@ -173,7 +173,12 @@ impl Default for Settings {
alive: true,
mute_sfx: false,
noise_cancellation_mode: 0,
noise_cancellation_modes: vec!["Off".to_string(), "On".to_string()],
noise_cancellation_modes: vec![
("Off".to_string(), 1.0),
("33%".to_string(), 0.66),
("66%".to_string(), 0.33),
("100%".to_string(), 0.0),
],
radio_mode: 1,
radio_modes: vec![
// see also: settings.is_radio_playing()
@ -181,8 +186,8 @@ impl Default for Settings {
"Space Wave Radio".to_string(),
"Amplify outside recordings".to_string(),
],
volume_sfx: 100,
volume_music: 100,
volume_sfx: 1.0,
volume_music: 1.0,
mouse_sensitivity: 0.4,
fov: 50.0,
fov_highspeed: 25.0,
@ -349,7 +354,15 @@ impl Settings {
value
};
self.noise_cancellation_mode = value;
self.mute_sfx = value >= 1;
self.volume_sfx = if let Some(noisecancel) = self
.noise_cancellation_modes
.get(self.noise_cancellation_mode)
{
noisecancel.1
} else {
self.noise_cancellation_modes[0].1
};
self.mute_sfx = value >= 3;
}
}