Unstable 0.1300.0.3

This commit is contained in:
Markus Isberg
2021-03-25 15:40:24 +02:00
parent 874616027b
commit 58c50a235d
136 changed files with 2486 additions and 1008 deletions
@@ -30,6 +30,7 @@ namespace Barotrauma.Sounds
public override int FillStreamBuffer(int samplePos, short[] buffer)
{
if (!Stream) throw new Exception("Called FillStreamBuffer on a non-streamed sound!");
if (reader == null) throw new Exception("Called FillStreamBuffer when the reader is null!");
if (samplePos >= reader.TotalSamples * reader.Channels * 2) return 0;
@@ -73,6 +74,8 @@ namespace Barotrauma.Sounds
{
if (!Stream)
{
reader ??= new VorbisReader(Filename);
reader.DecodedPosition = 0;
int bufferSize = (int)reader.TotalSamples * reader.Channels;
@@ -126,7 +129,7 @@ namespace Barotrauma.Sounds
{
if (Stream)
{
reader.Dispose();
reader?.Dispose();
}
base.Dispose();
@@ -14,35 +14,15 @@ namespace Barotrauma.Sounds
get { return disposed; }
}
public SoundManager Owner
{
get;
protected set;
}
public readonly SoundManager Owner;
public string Filename
{
get;
protected set;
}
public readonly string Filename;
public XElement XElement
{
get;
protected set;
}
public readonly XElement XElement;
public bool Stream
{
get;
protected set;
}
public readonly bool Stream;
public bool StreamsReliably
{
get;
protected set;
}
public readonly bool StreamsReliably;
public virtual SoundManager.SourcePoolIndex SourcePoolIndex
{
@@ -79,10 +59,10 @@ namespace Barotrauma.Sounds
public float BaseNear;
public float BaseFar;
public Sound(SoundManager owner, string filename, bool stream, bool streamsReliably, XElement xElement=null)
public Sound(SoundManager owner, string filename, bool stream, bool streamsReliably, XElement xElement=null, bool getFullPath=true)
{
Owner = owner;
Filename = Path.GetFullPath(filename.CleanUpPath()).CleanUpPath();
Filename = getFullPath ? Path.GetFullPath(filename.CleanUpPath()).CleanUpPath() : filename;
Stream = stream;
StreamsReliably = streamsReliably;
XElement = xElement;
@@ -21,12 +21,14 @@ namespace Barotrauma
public readonly string requiredTag;
public DamageSound(Sound sound, Vector2 damageRange, string damageType, string requiredTag = "")
public bool ignoreMuffling;
public DamageSound(Sound sound, Vector2 damageRange, string damageType, bool ignoreMuffling, string requiredTag = "")
{
this.sound = sound;
this.damageRange = damageRange;
this.damageType = damageType;
this.ignoreMuffling = ignoreMuffling;
this.requiredTag = requiredTag;
}
}
@@ -269,6 +271,7 @@ namespace Barotrauma
damageSound,
soundElement.GetAttributeVector2("damagerange", Vector2.Zero),
damageSoundType,
soundElement.GetAttributeBool("ignoremuffling", false),
soundElement.GetAttributeString("requiredtag", "")));
break;
@@ -531,7 +534,7 @@ namespace Barotrauma
Vector2 diff = gap.WorldPosition - listenerPos;
if (Math.Abs(diff.X) < FlowSoundRange && Math.Abs(diff.Y) < FlowSoundRange)
{
if (gap.Open < 0.01f) { continue; }
if (gap.Open < 0.01f || gap.LerpedFlowForce.LengthSquared() < 100.0f) { continue; }
float gapFlow = Math.Abs(gap.LerpedFlowForce.X) + Math.Abs(gap.LerpedFlowForce.Y) * 2.5f;
if (!gap.IsRoomToRoom) { gapFlow *= 2.0f; }
if (gapFlow < 10.0f) { continue; }
@@ -1123,7 +1126,11 @@ namespace Barotrauma
tempList.Add(s);
}
}
tempList.GetRandom().sound?.Play(1.0f, range, position, muffle: ShouldMuffleSound(Character.Controlled, position, range, null));
var damageSound = tempList.GetRandom();
if (damageSound.sound != null)
{
damageSound.sound.Play(1.0f, range, position, muffle: !damageSound.ignoreMuffling && ShouldMuffleSound(Character.Controlled, position, range, null));
}
}
public static void PlayUISound(GUISoundType soundType)
@@ -63,10 +63,8 @@ namespace Barotrauma.Sounds
get { return soundChannel?.CurrentAmplitude ?? 0.0f; }
}
public VoipSound(string name, SoundManager owner, VoipQueue q) : base(owner, "voip", true, true)
public VoipSound(string name, SoundManager owner, VoipQueue q) : base(owner, $"VoIP ({name})", true, true, getFullPath: false)
{
Filename = $"VoIP ({name})";
VoipConfig.SetupEncoding();
ALFormat = Al.FormatMono16;