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

View File

@@ -272,6 +272,7 @@ namespace Barotrauma
var cinematic = new TransitionCinematic(leavingSubs, GameMain.GameScreen.Cam, 5.0f);
SoundPlayer.OverrideMusicType = CrewManager.GetCharacters().Any(c => !c.IsDead) ? "endround" : "crewdead";
SoundPlayer.OverrideMusicDuration = 18.0f;
CoroutineManager.StartCoroutine(EndCinematic(cinematic), "EndCinematic");
@@ -282,18 +283,12 @@ namespace Barotrauma
{
while (cinematic.Running)
{
if (Submarine.MainSub == null) yield return CoroutineStatus.Success;
if (Submarine.MainSub == null) yield return CoroutineStatus.Success;
yield return CoroutineStatus.Running;
}
if (Submarine.MainSub == null) yield return CoroutineStatus.Success;
End("");
yield return new WaitForSeconds(18.0f);
SoundPlayer.OverrideMusicType = null;
if (Submarine.MainSub != null) End("");
yield return CoroutineStatus.Success;
}

View File

@@ -39,6 +39,7 @@ namespace Barotrauma
if (!singleplayer)
{
SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround";
SoundPlayer.OverrideMusicDuration = 18.0f;
}
string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" :

View File

@@ -335,6 +335,7 @@ namespace Barotrauma
}
SoundPlayer.OverrideMusicType = "none";
SoundPlayer.OverrideMusicDuration = null;
for (int i = 0; i < Sounds.SoundManager.DefaultSourceCount; i++)
{
Sounds.SoundManager.Pause(i);

View File

@@ -86,6 +86,8 @@ namespace Barotrauma
set;
}
public static float? OverrideMusicDuration;
public static int SoundCount;
public static IEnumerable<object> Init()
@@ -278,6 +280,16 @@ namespace Barotrauma
{
if (musicClips == null) return;
if (OverrideMusicType != null && OverrideMusicDuration.HasValue)
{
OverrideMusicDuration -= deltaTime;
if (OverrideMusicDuration <= 0.0f)
{
OverrideMusicType = null;
OverrideMusicDuration = null;
}
}
updateMusicTimer -= deltaTime;
if (updateMusicTimer <= 0.0f)
{

View File

@@ -1514,9 +1514,7 @@ namespace Barotrauma.Networking
{
yield return CoroutineStatus.Running;
} while (cinematic.Running);
#if CLIENT
SoundPlayer.OverrideMusicType = null;
#endif
Submarine.Unload();
entityEventManager.Clear();