mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-01 03:32:38 +00:00
Change thruster sounds when underwater
This commit is contained in:
parent
4fd8f40667
commit
7c8a765eb6
@ -17,10 +17,31 @@ internal class QSBJetpackThrusterAudio : QSBThrusterAudio
|
|||||||
// Taken from Player_Body settings
|
// Taken from Player_Body settings
|
||||||
private const float maxTranslationalThrust = 6f;
|
private const float maxTranslationalThrust = 6f;
|
||||||
|
|
||||||
|
private bool _underwater;
|
||||||
|
private RemotePlayerFluidDetector _fluidDetector;
|
||||||
|
|
||||||
public void Init(PlayerInfo player)
|
public void Init(PlayerInfo player)
|
||||||
{
|
{
|
||||||
_attachedPlayer = player;
|
_attachedPlayer = player;
|
||||||
enabled = true;
|
enabled = true;
|
||||||
|
|
||||||
|
_fluidDetector = player.FluidDetector;
|
||||||
|
_fluidDetector.OnEnterFluidType += OnEnterExitFluidType;
|
||||||
|
_fluidDetector.OnExitFluidType += OnEnterExitFluidType;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
if (_fluidDetector != null)
|
||||||
|
{
|
||||||
|
_fluidDetector.OnEnterFluidType -= OnEnterExitFluidType;
|
||||||
|
_fluidDetector.OnExitFluidType -= OnEnterExitFluidType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnterExitFluidType(FluidVolume.Type type)
|
||||||
|
{
|
||||||
|
_underwater = _fluidDetector.InFluidType(FluidVolume.Type.WATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
@ -37,13 +58,12 @@ internal class QSBJetpackThrusterAudio : QSBThrusterAudio
|
|||||||
// TODO: Sync
|
// TODO: Sync
|
||||||
var usingBooster = false;
|
var usingBooster = false;
|
||||||
var usingOxygen = false;
|
var usingOxygen = false;
|
||||||
var underwater = false;
|
|
||||||
|
|
||||||
float targetVolume = usingBooster ? 0f : thrustFraction;
|
float targetVolume = usingBooster ? 0f : thrustFraction;
|
||||||
float targetPan = -acc.x / maxTranslationalThrust * 0.4f;
|
float targetPan = -acc.x / maxTranslationalThrust * 0.4f;
|
||||||
UpdateTranslationalSource(_translationalSource, targetVolume, targetPan, !underwater && !usingOxygen);
|
UpdateTranslationalSource(_translationalSource, targetVolume, targetPan, !_underwater && !usingOxygen);
|
||||||
UpdateTranslationalSource(_underwaterSource, targetVolume, targetPan, underwater);
|
UpdateTranslationalSource(_underwaterSource, targetVolume, targetPan, _underwater);
|
||||||
UpdateTranslationalSource(_oxygenSource, targetVolume, targetPan, !underwater && usingOxygen);
|
UpdateTranslationalSource(_oxygenSource, targetVolume, targetPan, !_underwater && usingOxygen);
|
||||||
|
|
||||||
if (!_wasBoosting && usingBooster)
|
if (!_wasBoosting && usingBooster)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user