Fixed EndRound music looping forever. Closes #334

This commit is contained in:
Joonas Rikkonen
2018-04-18 11:02:58 +03:00
parent 9a8f13140e
commit edf5bacc89
5 changed files with 18 additions and 11 deletions
@@ -272,6 +272,7 @@ namespace Barotrauma
var cinematic = new TransitionCinematic(leavingSubs, GameMain.GameScreen.Cam, 5.0f); var cinematic = new TransitionCinematic(leavingSubs, GameMain.GameScreen.Cam, 5.0f);
SoundPlayer.OverrideMusicType = CrewManager.GetCharacters().Any(c => !c.IsDead) ? "endround" : "crewdead"; SoundPlayer.OverrideMusicType = CrewManager.GetCharacters().Any(c => !c.IsDead) ? "endround" : "crewdead";
SoundPlayer.OverrideMusicDuration = 18.0f;
CoroutineManager.StartCoroutine(EndCinematic(cinematic), "EndCinematic"); CoroutineManager.StartCoroutine(EndCinematic(cinematic), "EndCinematic");
@@ -287,13 +288,7 @@ namespace Barotrauma
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
} }
if (Submarine.MainSub == null) yield return CoroutineStatus.Success; if (Submarine.MainSub != null) End("");
End("");
yield return new WaitForSeconds(18.0f);
SoundPlayer.OverrideMusicType = null;
yield return CoroutineStatus.Success; yield return CoroutineStatus.Success;
} }
@@ -39,6 +39,7 @@ namespace Barotrauma
if (!singleplayer) if (!singleplayer)
{ {
SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround"; SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround";
SoundPlayer.OverrideMusicDuration = 18.0f;
} }
string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" : string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" :
@@ -335,6 +335,7 @@ namespace Barotrauma
} }
SoundPlayer.OverrideMusicType = "none"; SoundPlayer.OverrideMusicType = "none";
SoundPlayer.OverrideMusicDuration = null;
for (int i = 0; i < Sounds.SoundManager.DefaultSourceCount; i++) for (int i = 0; i < Sounds.SoundManager.DefaultSourceCount; i++)
{ {
Sounds.SoundManager.Pause(i); Sounds.SoundManager.Pause(i);
@@ -86,6 +86,8 @@ namespace Barotrauma
set; set;
} }
public static float? OverrideMusicDuration;
public static int SoundCount; public static int SoundCount;
public static IEnumerable<object> Init() public static IEnumerable<object> Init()
@@ -278,6 +280,16 @@ namespace Barotrauma
{ {
if (musicClips == null) return; if (musicClips == null) return;
if (OverrideMusicType != null && OverrideMusicDuration.HasValue)
{
OverrideMusicDuration -= deltaTime;
if (OverrideMusicDuration <= 0.0f)
{
OverrideMusicType = null;
OverrideMusicDuration = null;
}
}
updateMusicTimer -= deltaTime; updateMusicTimer -= deltaTime;
if (updateMusicTimer <= 0.0f) if (updateMusicTimer <= 0.0f)
{ {
@@ -1514,9 +1514,7 @@ namespace Barotrauma.Networking
{ {
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
} while (cinematic.Running); } while (cinematic.Running);
#if CLIENT
SoundPlayer.OverrideMusicType = null;
#endif
Submarine.Unload(); Submarine.Unload();
entityEventManager.Clear(); entityEventManager.Clear();