Merge pull request #2369 from kacpherek/fix/air-bubble-pop-sound

🤖 Agent: Merged by Ludovic's AI agent (Claude, contrib-gate-19) after the contribution gate. Checked against vanilla 26.3 and proven in union/cg19-r2 (all round-2 PRs together: clippy, 1722 tests, 135 harnesses, lan_e2e in-frame and on the server thread) and union/cg19-r3 (the same PRs merged with today's main: 96/96 harnesses). Thanks @kacpherek.
This commit is contained in:
Ludovic Marie
2026-10-27 17:51:11 +01:00
committed by GitHub
2 changed files with 28 additions and 0 deletions
+13
View File
@@ -5989,6 +5989,19 @@ impl Game<'_> {
.health_hud
.left_height
.max(self.health_hud.right_height);
// Hud.playAirBubblePoppedSound: Player.playSound (PLAYERS), heard
// by this client only.
if let Some((volume, pitch)) = self.health_hud.bubble_pop_sound.take() {
let at = [p.position.x, p.position.y, p.position.z];
let players = horizon_client::settings::SOUND_SOURCES
.iter()
.position(|s| *s == "player")
.unwrap_or(0);
let capture = self.audio.capture.take();
self.audio
.play_on(players, "ui.hud.bubble_pop", Some(at), volume, pitch);
self.audio.capture = capture;
}
}
if contextual == ContextualBar::Locator {
let draws = self.locator_bar_draws(wi, hi);
+15
View File
@@ -490,6 +490,11 @@ pub struct HealthHud {
/// above them.
pub left_height: i32,
pub right_height: i32,
/// `Hud.lastBubblePopSoundPlayed`.
pub last_bubble_pop_sound: i32,
/// The `ui.hud.bubble_pop` volume and pitch `playAirBubblePoppedSound`
/// asked for this frame; the caller plays it and clears it.
pub bubble_pop_sound: Option<(f32, f32)>,
}
pub struct HealthInputs {
@@ -761,12 +766,22 @@ impl HealthHud {
let popping = bubble(0);
let delay = i32::from(air != 0 && i.under_water);
let empty = 10 - bubble(delay);
if !i.under_water {
self.last_bubble_pop_sound = 0;
}
for b in 1..=10 {
let x = x_right - (b - 1) * 8 - 9;
if b <= full {
out.push(sprite("hud/air", x, y, 9, 9));
} else if full != popping && b == popping && i.under_water {
out.push(sprite("hud/air_bursting", x, y, 9, 9));
// Hud.playAirBubblePoppedSound.
if self.last_bubble_pop_sound != b {
let volume = 0.5 + 0.1 * (empty - 3 + 1).max(0) as f32;
let pitch = 1.0 + 0.1 * (empty - 5 + 1).max(0) as f32;
self.bubble_pop_sound = Some((volume, pitch));
self.last_bubble_pop_sound = b;
}
} else if b > 10 - empty {
let wobble = if empty == 10 && i.tick % 2 == 0 {
next(2)