v0.13.0.11
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -195,14 +197,21 @@ namespace Barotrauma
|
||||
{
|
||||
case "music":
|
||||
var newMusicClip = new BackgroundMusic(soundElement);
|
||||
musicClips.AddIfNotNull(newMusicClip);
|
||||
if (loadedSoundElements != null)
|
||||
if (File.Exists(newMusicClip.File))
|
||||
{
|
||||
if (newMusicClip.Type.Equals("menu", StringComparison.OrdinalIgnoreCase))
|
||||
musicClips.AddIfNotNull(newMusicClip);
|
||||
if (loadedSoundElements != null)
|
||||
{
|
||||
targetMusic[0] = newMusicClip;
|
||||
if (newMusicClip.Type.Equals("menu", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
targetMusic[0] = newMusicClip;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.NewMessage($"Music file \"{newMusicClip.File}\" not found.");
|
||||
}
|
||||
break;
|
||||
case "splash":
|
||||
SplashSounds.AddIfNotNull(GameMain.SoundManager.LoadSound(soundElement, false));
|
||||
@@ -262,6 +271,7 @@ namespace Barotrauma
|
||||
damageSound,
|
||||
soundElement.GetAttributeVector2("damagerange", Vector2.Zero),
|
||||
damageSoundType,
|
||||
soundElement.GetAttributeBool("ignoremuffling", false),
|
||||
soundElement.GetAttributeString("requiredtag", "")));
|
||||
|
||||
break;
|
||||
@@ -524,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; }
|
||||
@@ -887,7 +897,17 @@ namespace Barotrauma
|
||||
if (currentMusic[i] == null || (musicChannel[i] == null || !musicChannel[i].IsPlaying))
|
||||
{
|
||||
DisposeMusicChannel(i);
|
||||
currentMusic[i] = GameMain.SoundManager.LoadSound(targetMusic[i].File, true);
|
||||
try
|
||||
{
|
||||
currentMusic[i] = GameMain.SoundManager.LoadSound(targetMusic[i].File, true);
|
||||
}
|
||||
catch (System.IO.InvalidDataException e)
|
||||
{
|
||||
DebugConsole.ThrowError($"Failed to load the music clip \"{targetMusic[i].File}\".", e);
|
||||
musicClips.Remove(targetMusic[i]);
|
||||
targetMusic[i] = null;
|
||||
break;
|
||||
}
|
||||
musicChannel[i] = currentMusic[i].Play(0.0f, "music");
|
||||
if (targetMusic[i].ContinueFromPreviousTime)
|
||||
{
|
||||
@@ -983,13 +1003,17 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Submarine targetSubmarine = Character.Controlled?.Submarine;
|
||||
if ((targetSubmarine != null && targetSubmarine.AtDamageDepth) ||
|
||||
(GameMain.GameScreen != null && Screen.Selected == GameMain.GameScreen && Level.Loaded != null && Level.Loaded.GetRealWorldDepth(GameMain.GameScreen.Cam.Position.Y) > Level.Loaded.RealWorldCrushDepth))
|
||||
if (targetSubmarine != null && targetSubmarine.AtDamageDepth)
|
||||
{
|
||||
return "deep";
|
||||
}
|
||||
if (GameMain.GameScreen != null && Screen.Selected == GameMain.GameScreen && Submarine.MainSub != null &&
|
||||
Level.Loaded != null && Level.Loaded.GetRealWorldDepth(GameMain.GameScreen.Cam.Position.Y) > Submarine.MainSub.RealWorldCrushDepth)
|
||||
{
|
||||
return "deep";
|
||||
}
|
||||
|
||||
if (targetSubmarine != null)
|
||||
if (targetSubmarine != null)
|
||||
{
|
||||
float floodedArea = 0.0f;
|
||||
float totalArea = 0.0f;
|
||||
@@ -1033,7 +1057,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.GameSession != null)
|
||||
{
|
||||
if (Submarine.Loaded != null && Level.Loaded != null && Submarine.MainSub != null && Submarine.MainSub.AtEndPosition)
|
||||
if (Submarine.Loaded != null && Level.Loaded != null && Submarine.MainSub != null && Submarine.MainSub.AtEndExit)
|
||||
{
|
||||
return "levelend";
|
||||
}
|
||||
@@ -1102,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)
|
||||
|
||||
Reference in New Issue
Block a user