v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -122,7 +122,7 @@ namespace Barotrauma.Sounds
static void MuffleBuffer(float[] buffer, int sampleRate)
{
var filter = new LowpassFilter(sampleRate, 1600);
var filter = new LowpassFilter(sampleRate, SoundPlayer.MuffleFilterFrequency);
filter.Process(buffer);
}
@@ -13,7 +13,7 @@ namespace Barotrauma.Sounds
private set;
}
public SoundSourcePool(int sourceCount = SoundManager.SOURCE_COUNT)
public SoundSourcePool(int sourceCount = SoundManager.SourceCount)
{
int alError;
@@ -11,7 +11,12 @@ namespace Barotrauma.Sounds
{
class SoundManager : IDisposable
{
public const int SOURCE_COUNT = 32;
public const int SourceCount = 32;
public const string SoundCategoryDefault = "default";
public const string SoundCategoryUi = "ui";
public const string SoundCategoryWaterAmbience = "waterambience";
public const string SoundCategoryMusic = "music";
public const string SoundCategoryVoip = "voip";
public bool Disabled
{
@@ -204,7 +209,7 @@ namespace Barotrauma.Sounds
updateChannelsThread = null;
sourcePools = new SoundSourcePool[2];
playingChannels[(int)SourcePoolIndex.Default] = new SoundChannel[SOURCE_COUNT];
playingChannels[(int)SourcePoolIndex.Default] = new SoundChannel[SourceCount];
playingChannels[(int)SourcePoolIndex.Voice] = new SoundChannel[16];
string deviceName = GameSettings.CurrentConfig.Audio.AudioOutputDevice;
@@ -334,7 +339,7 @@ namespace Barotrauma.Sounds
return false;
}
sourcePools[(int)SourcePoolIndex.Default] = new SoundSourcePool(SOURCE_COUNT);
sourcePools[(int)SourcePoolIndex.Default] = new SoundSourcePool(SourceCount);
sourcePools[(int)SourcePoolIndex.Voice] = new SoundSourcePool(16);
ReloadSounds();
@@ -353,11 +358,19 @@ namespace Barotrauma.Sounds
throw new System.IO.FileNotFoundException("Sound file \"" + filename + "\" doesn't exist!");
}
#if DEBUG
System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
sw.Start();
#endif
Sound newSound = new OggSound(this, filename, stream, null);
lock (loadedSounds)
{
loadedSounds.Add(newSound);
}
#if DEBUG
sw.Stop();
System.Diagnostics.Debug.WriteLine($"Loaded sound \"{filename}\" ({sw.ElapsedMilliseconds} ms).");
#endif
return newSound;
}
@@ -672,10 +685,10 @@ namespace Barotrauma.Sounds
{
voipAttenuatedGain = 1.0f;
}
SetCategoryGainMultiplier("default", VoipAttenuatedGain, 1);
SetCategoryGainMultiplier("ui", VoipAttenuatedGain, 1);
SetCategoryGainMultiplier("waterambience", VoipAttenuatedGain, 1);
SetCategoryGainMultiplier("music", VoipAttenuatedGain, 1);
SetCategoryGainMultiplier(SoundCategoryDefault, VoipAttenuatedGain, 1);
SetCategoryGainMultiplier(SoundCategoryUi, VoipAttenuatedGain, 1);
SetCategoryGainMultiplier(SoundCategoryWaterAmbience, VoipAttenuatedGain, 1);
SetCategoryGainMultiplier(SoundCategoryMusic, VoipAttenuatedGain, 1);
if (GameSettings.CurrentConfig.Audio.DynamicRangeCompressionEnabled)
{
@@ -721,11 +734,11 @@ namespace Barotrauma.Sounds
public void ApplySettings()
{
SetCategoryGainMultiplier("default", GameSettings.CurrentConfig.Audio.SoundVolume, 0);
SetCategoryGainMultiplier("ui", GameSettings.CurrentConfig.Audio.UiVolume, 0);
SetCategoryGainMultiplier("waterambience", GameSettings.CurrentConfig.Audio.SoundVolume, 0);
SetCategoryGainMultiplier("music", GameSettings.CurrentConfig.Audio.MusicVolume, 0);
SetCategoryGainMultiplier("voip", Math.Min(GameSettings.CurrentConfig.Audio.VoiceChatVolume, 1.0f), 0);
SetCategoryGainMultiplier(SoundCategoryDefault, GameSettings.CurrentConfig.Audio.SoundVolume, 0);
SetCategoryGainMultiplier(SoundCategoryUi, GameSettings.CurrentConfig.Audio.UiVolume, 0);
SetCategoryGainMultiplier(SoundCategoryWaterAmbience, GameSettings.CurrentConfig.Audio.SoundVolume, 0);
SetCategoryGainMultiplier(SoundCategoryMusic, GameSettings.CurrentConfig.Audio.MusicVolume, 0);
SetCategoryGainMultiplier(SoundCategoryVoip, Math.Min(GameSettings.CurrentConfig.Audio.VoiceChatVolume, 1.0f), 0);
}
/// <summary>
@@ -1,12 +1,11 @@
using Barotrauma.Extensions;
using Barotrauma.IO;
using Barotrauma.Sounds;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using Barotrauma.IO;
using System.Linq;
using System.Threading;
using System.Xml.Linq;
namespace Barotrauma
{
@@ -16,6 +15,8 @@ namespace Barotrauma
private const float MusicLerpSpeed = 1.0f;
private const float UpdateMusicInterval = 5.0f;
public const float MuffleFilterFrequency = 600;
const int MaxMusicChannels = 6;
private readonly static BackgroundMusic[] currentMusic = new BackgroundMusic[MaxMusicChannels];
@@ -28,9 +29,9 @@ namespace Barotrauma
private static float updateMusicTimer;
//ambience
private static Sound waterAmbienceIn => SoundPrefab.WaterAmbienceIn.ActivePrefab.Sound;
private static Sound waterAmbienceOut => SoundPrefab.WaterAmbienceOut.ActivePrefab.Sound;
private static Sound waterAmbienceMoving => SoundPrefab.WaterAmbienceMoving.ActivePrefab.Sound;
private static SoundPrefab waterAmbienceIn => SoundPrefab.WaterAmbienceIn.ActivePrefab;
private static SoundPrefab waterAmbienceOut => SoundPrefab.WaterAmbienceOut.ActivePrefab;
private static SoundPrefab waterAmbienceMoving => SoundPrefab.WaterAmbienceMoving.ActivePrefab;
private static readonly HashSet<SoundChannel> waterAmbienceChannels = new HashSet<SoundChannel>();
private static float ambientSoundTimer;
@@ -213,9 +214,9 @@ namespace Barotrauma
}
}
updateWaterAmbience(waterAmbienceIn, ambienceVolume * (1.0f - movementSoundVolume) * insideSubFactor);
updateWaterAmbience(waterAmbienceMoving, ambienceVolume * movementSoundVolume * insideSubFactor);
updateWaterAmbience(waterAmbienceOut, 1.0f - insideSubFactor);
updateWaterAmbience(waterAmbienceIn.Sound, ambienceVolume * (1.0f - movementSoundVolume) * insideSubFactor * waterAmbienceIn.Volume);
updateWaterAmbience(waterAmbienceMoving.Sound, ambienceVolume * movementSoundVolume * insideSubFactor * waterAmbienceMoving.Volume);
updateWaterAmbience(waterAmbienceOut.Sound, (1.0f - insideSubFactor) * waterAmbienceOut.Volume);
}
private static void UpdateWaterFlowSounds(float deltaTime)
@@ -956,7 +957,7 @@ namespace Barotrauma
PlayDamageSound(damageType, damage, bodyPosition, 800.0f);
}
public static void PlayDamageSound(string damageType, float damage, Vector2 position, float range = 2000.0f, IEnumerable<Identifier> tags = null)
public static void PlayDamageSound(string damageType, float damage, Vector2 position, float range = 2000.0f, IEnumerable<Identifier> tags = null, float gain = 1.0f)
{
var suitableSounds = damageSounds.Where(s =>
s.DamageType == damageType &&
@@ -972,7 +973,7 @@ namespace Barotrauma
s.DamageRange == Vector2.Zero || (randomizedDamage >= s.DamageRange.X && randomizedDamage <= s.DamageRange.Y));
var damageSound = suitableSounds.GetRandomUnsynced();
damageSound?.Sound?.Play(1.0f, range, position, muffle: !damageSound.IgnoreMuffling && ShouldMuffleSound(Character.Controlled, position, range, null));
damageSound?.Sound?.Play(gain, range, position, muffle: !damageSound.IgnoreMuffling && ShouldMuffleSound(Character.Controlled, position, range, null));
}
public static void PlayUISound(GUISoundType soundType)
@@ -183,6 +183,9 @@ namespace Barotrauma
public readonly ContentPath SoundPath;
public readonly ContentXElement Element;
public readonly Identifier ElementName;
public readonly float Volume;
public Sound Sound { get; private set; }
public SoundPrefab(ContentXElement element, SoundsFile file, bool stream = false) : base(file, element)
@@ -191,6 +194,8 @@ namespace Barotrauma
Element = element;
ElementName = element.NameAsIdentifier();
Sound = GameMain.SoundManager.LoadSound(element, stream: stream);
Volume = element.GetAttributeFloat(nameof(Volume), 1.0f);
}
public bool IsPlaying()
@@ -235,7 +240,6 @@ namespace Barotrauma
public readonly Identifier Type;
public readonly bool DuckVolume;
public readonly float Volume;
public readonly Vector2 IntensityRange;
public readonly bool MuteIntensityTracks;
@@ -255,7 +259,6 @@ namespace Barotrauma
{
ForceIntensityTrack = element.GetAttributeFloat(nameof(ForceIntensityTrack), 0.0f);
}
Volume = element.GetAttributeFloat(nameof(Volume), 1.0f);
StartFromRandomTime = element.GetAttributeBool(nameof(StartFromRandomTime), false);
ContinueFromPreviousTime = element.GetAttributeBool(nameof(ContinueFromPreviousTime), false);
}