At this point all sfx should be able to detect underwater

This commit is contained in:
DaforLynx 2022-03-22 22:39:06 -07:00 committed by IsseW
parent 088d1cfe9d
commit 365f45397b

View File

@ -175,6 +175,21 @@ impl SessionState {
self.scene
.maintain_debug_hitboxes(&client, &global_state.settings, &mut self.hitboxes);
// All this camera code is just to determine if it's underwater for the sfx filter
let camera = self.scene.camera_mut();
camera.compute_dependents(&*client.state().terrain());
let camera::Dependents {
cam_pos, ..
} = self.scene.camera().dependents();
let focus_pos = self.scene.camera().get_focus_pos();
let focus_off = focus_pos.map(|e| e.trunc());
let cam_pos = cam_pos + focus_off;
let underwater = client.state()
.terrain()
.get(cam_pos.map(|e| e.floor() as i32))
.map(|b| b.is_liquid())
.unwrap_or(false);
#[cfg(not(target_os = "macos"))]
{
// Update mumble positional audio
@ -261,7 +276,7 @@ impl SessionState {
}
_ => global_state
.audio
.emit_sfx(sfx_trigger_item, client.position().unwrap_or_default(), Some(1.0), false)
.emit_sfx(sfx_trigger_item, client.position().unwrap_or_default(), Some(1.0), underwater)
}