v0.14.6.0

This commit is contained in:
Joonas Rikkonen
2021-06-17 17:54:52 +03:00
parent 3f324b14e8
commit c27e2ea5ab
348 changed files with 13156 additions and 4266 deletions
@@ -72,6 +72,8 @@ namespace Barotrauma
private readonly static BackgroundMusic[] targetMusic = new BackgroundMusic[MaxMusicChannels];
private static List<BackgroundMusic> musicClips;
private static BackgroundMusic previousDefaultMusic;
private static float updateMusicTimer;
//ambience
@@ -824,22 +826,58 @@ namespace Barotrauma
IEnumerable<BackgroundMusic> suitableMusic = GetSuitableMusicClips(currentMusicType, currentIntensity);
int mainTrackIndex = 0;
if (suitableMusic.Count() == 0)
{
targetMusic[0] = null;
targetMusic[mainTrackIndex] = null;
}
//switch the music if nothing playing atm or the currently playing clip is not suitable anymore
else if (targetMusic[0] == null || currentMusic[0] == null || !suitableMusic.Any(m => m.File == currentMusic[0].Filename))
else if (targetMusic[mainTrackIndex] == null || currentMusic[mainTrackIndex] == null || !currentMusic[mainTrackIndex].IsPlaying() || !suitableMusic.Any(m => m.File == currentMusic[mainTrackIndex].Filename))
{
targetMusic[0] = suitableMusic.GetRandom();
if (currentMusicType == "default")
{
if (previousDefaultMusic == null)
{
targetMusic[mainTrackIndex] = previousDefaultMusic = suitableMusic.GetRandom();
}
else
{
targetMusic[mainTrackIndex] = previousDefaultMusic;
}
}
else
{
targetMusic[mainTrackIndex] = suitableMusic.GetRandom();
}
}
if (Level.Loaded?.Type == LevelData.LevelType.LocationConnection)
{
// Find background noise loop for the current biome
IEnumerable<BackgroundMusic> suitableNoiseLoops = Screen.Selected == GameMain.GameScreen ?
GetSuitableMusicClips(Level.Loaded.LevelData?.Biome?.Identifier, currentIntensity) :
Enumerable.Empty<BackgroundMusic>();
int noiseLoopIndex = 1;
if (suitableNoiseLoops.Count() == 0)
{
targetMusic[noiseLoopIndex] = null;
}
// Switch the noise loop if nothing playing atm or the currently playing clip is not suitable anymore
else if (targetMusic[noiseLoopIndex] == null || currentMusic[noiseLoopIndex] == null || !suitableNoiseLoops.Any(m => m.File == currentMusic[noiseLoopIndex].Filename))
{
targetMusic[noiseLoopIndex] = suitableNoiseLoops.GetRandom();
}
}
//get the appropriate intensity layers for current situation
IEnumerable<BackgroundMusic> suitableIntensityMusic = Screen.Selected == GameMain.GameScreen ?
GetSuitableMusicClips("intensity", currentIntensity) :
Enumerable.Empty<BackgroundMusic>();
for (int i = 1; i < MaxMusicChannels; i++)
int intensityTrackStartIndex = 2;
for (int i = intensityTrackStartIndex; i < MaxMusicChannels; i++)
{
//disable targetmusics that aren't suitable anymore
if (targetMusic[i] != null && !suitableIntensityMusic.Any(m => m.File == targetMusic[i].File))
@@ -851,9 +889,9 @@ namespace Barotrauma
foreach (BackgroundMusic intensityMusic in suitableIntensityMusic)
{
//already playing, do nothing
if (targetMusic.Any(m => m != null && m.File == intensityMusic.File)) continue;
if (targetMusic.Any(m => m != null && m.File == intensityMusic.File)) { continue; }
for (int i = 1; i < MaxMusicChannels; i++)
for (int i = intensityTrackStartIndex; i < MaxMusicChannels; i++)
{
if (targetMusic[i] == null)
{
@@ -861,7 +899,7 @@ namespace Barotrauma
break;
}
}
}
}
updateMusicTimer = UpdateMusicInterval;
}
@@ -973,7 +1011,11 @@ namespace Barotrauma
return "editor";
}
if (Screen.Selected != GameMain.GameScreen) { return firstTimeInMainMenu ? "menu" : "default"; }
if (Screen.Selected != GameMain.GameScreen)
{
previousDefaultMusic = null;
return firstTimeInMainMenu ? "menu" : "default";
}
firstTimeInMainMenu = false;
@@ -114,10 +114,7 @@ namespace Barotrauma.Sounds
{
lock (mutex)
{
if (soundChannel != null)
{
soundChannel.Dispose();
}
soundChannel?.Dispose();
base.Dispose();
}
}