Build 0.20.7.0

This commit is contained in:
Markus Isberg
2022-11-18 18:13:38 +02:00
parent 8c8fd865c5
commit ecb6d40b4b
111 changed files with 1346 additions and 701 deletions
@@ -14,6 +14,16 @@ namespace Barotrauma.Networking
set;
}
private SoundChannel radioNoiseChannel;
private float radioNoise;
public float RadioNoise
{
get { return radioNoise; }
set { radioNoise = MathHelper.Clamp(value, 0.0f, 1.0f); }
}
private bool mutedLocally;
public bool MutedLocally
{
@@ -42,35 +52,64 @@ namespace Barotrauma.Networking
!HasPermission(ClientPermissions.Kick) &&
!HasPermission(ClientPermissions.Unban);
public void UpdateSoundPosition()
public void UpdateVoipSound()
{
if (VoipSound == null) { return; }
if (!VoipSound.IsPlaying)
if (VoipSound == null || !VoipSound.IsPlaying)
{
DebugConsole.Log("Destroying voipsound");
VoipSound.Dispose();
radioNoiseChannel?.Dispose();
radioNoiseChannel = null;
if (VoipSound != null)
{
DebugConsole.Log("Destroying voipsound");
VoipSound.Dispose();
}
VoipSound = null;
return;
return;
}
if (Screen.Selected is ModDownloadScreen)
{
VoipSound.Gain = 0.0f;
}
float gain = 1.0f;
float noiseGain = 0.0f;
Vector3? position = null;
if (character != null)
{
if (GameSettings.CurrentConfig.Audio.UseDirectionalVoiceChat)
{
VoipSound.SetPosition(new Vector3(character.WorldPosition.X, character.WorldPosition.Y, 0.0f));
position = new Vector3(character.WorldPosition.X, character.WorldPosition.Y, 0.0f);
}
else
{
VoipSound.SetPosition(null);
float dist = Vector3.Distance(new Vector3(character.WorldPosition, 0.0f), GameMain.SoundManager.ListenerPosition);
VoipSound.Gain = 1.0f - MathUtils.InverseLerp(VoipSound.Near, VoipSound.Far, dist);
gain = 1.0f - MathUtils.InverseLerp(VoipSound.Near, VoipSound.Far, dist);
}
if (RadioNoise > 0.0f)
{
noiseGain = gain * RadioNoise;
gain *= 1.0f - RadioNoise;
}
}
else
VoipSound.SetPosition(position);
VoipSound.Gain = gain;
if (noiseGain > 0.0f)
{
VoipSound.SetPosition(null);
VoipSound.Gain = 1.0f;
if (radioNoiseChannel == null || !radioNoiseChannel.IsPlaying)
{
radioNoiseChannel = SoundPlayer.PlaySound("radiostatic");
radioNoiseChannel.Category = "voip";
radioNoiseChannel.Looping = true;
}
radioNoiseChannel.Near = VoipSound.Near;
radioNoiseChannel.Far = VoipSound.Far;
radioNoiseChannel.Position = position;
radioNoiseChannel.Gain = noiseGain;
}
else if (radioNoiseChannel != null)
{
radioNoiseChannel.Gain = 0.0f;
}
}
@@ -158,6 +197,11 @@ namespace Barotrauma.Networking
VoipSound.Dispose();
VoipSound = null;
}
if (radioNoiseChannel != null)
{
radioNoiseChannel.Dispose();
radioNoiseChannel = null;
}
}
}
}