diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs index 41c0fd664..5a26a9a63 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/SinglePlayerCampaign.cs @@ -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; } diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs b/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs index f30ceecf4..28d19fe84 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/RoundSummary.cs @@ -39,6 +39,7 @@ namespace Barotrauma if (!singleplayer) { SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround"; + SoundPlayer.OverrideMusicDuration = 18.0f; } string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" : diff --git a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs index 5d78872a5..7c3cf0daf 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/SubEditorScreen.cs @@ -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); diff --git a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs index a0c4ee349..9fc6cce4a 100644 --- a/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs +++ b/Barotrauma/BarotraumaClient/Source/Sounds/SoundPlayer.cs @@ -86,6 +86,8 @@ namespace Barotrauma set; } + public static float? OverrideMusicDuration; + public static int SoundCount; public static IEnumerable 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) { diff --git a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs index 9c58d60a9..44683fc11 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/GameServer.cs @@ -1514,9 +1514,7 @@ namespace Barotrauma.Networking { yield return CoroutineStatus.Running; } while (cinematic.Running); -#if CLIENT - SoundPlayer.OverrideMusicType = null; -#endif + Submarine.Unload(); entityEventManager.Clear();