diff --git a/Content.Client/GameTicking/Managers/ClientGameTicker.cs b/Content.Client/GameTicking/Managers/ClientGameTicker.cs index ce478faf3d..518177458b 100644 --- a/Content.Client/GameTicking/Managers/ClientGameTicker.cs +++ b/Content.Client/GameTicking/Managers/ClientGameTicker.cs @@ -7,7 +7,9 @@ using Content.Shared.GameWindow; using JetBrains.Annotations; using Robust.Client.Graphics; using Robust.Client.State; +using Robust.Shared.Audio; using Robust.Shared.Network; +using Robust.Shared.Player; using Robust.Shared.Utility; namespace Content.Client.GameTicking.Managers @@ -23,6 +25,7 @@ namespace Content.Client.GameTicking.Managers [ViewVariables] public bool AreWeReady { get; private set; } [ViewVariables] public bool IsGameStarted { get; private set; } [ViewVariables] public string? LobbySong { get; private set; } + [ViewVariables] public string? RestartSound { get; private set; } [ViewVariables] public string? LobbyBackground { get; private set; } [ViewVariables] public bool DisallowedLateJoin { get; private set; } [ViewVariables] public string? ServerInfoBlob { get; private set; } @@ -55,6 +58,7 @@ namespace Content.Client.GameTicking.Managers }); SubscribeNetworkEvent(LateJoinStatus); SubscribeNetworkEvent(UpdateJobsAvailable); + SubscribeNetworkEvent(RoundRestartCleanup); Status = new Dictionary(); _initialized = true; @@ -128,8 +132,21 @@ namespace Content.Client.GameTicking.Managers Get().StartLobbyMusic(); } + RestartSound = message.RestartSound; + //This is not ideal at all, but I don't see an immediately better fit anywhere else. var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo); } + + private void RoundRestartCleanup(RoundRestartCleanupEvent ev) + { + if (string.IsNullOrEmpty(RestartSound)) + return; + + SoundSystem.Play(Filter.Empty(), RestartSound); + + // Cleanup the sound, we only want it to play when the round restarts after it ends normally. + RestartSound = null; + } } } diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index 8ffd628ce8..0e90bd097f 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -326,7 +326,10 @@ namespace Content.Server.GameTicking // This ordering mechanism isn't great (no ordering of minds) but functions var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray(); _playersInGame.Clear(); - RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId, listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong)); + + RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId, + listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong, + new SoundCollectionSpecifier("RoundEnd").GetSound())); } public void RestartRound() @@ -349,7 +352,6 @@ namespace Content.Server.GameTicking LobbySong = _robustRandom.Pick(_lobbyMusicCollection.PickFiles).ToString(); RandomizeLobbyBackground(); ResettingCleanup(); - SoundSystem.Play(Filter.Broadcast(), new SoundCollectionSpecifier("RoundEnd").GetSound()); if (!LobbyEnabled) { diff --git a/Content.Shared/GameTicking/SharedGameTicker.cs b/Content.Shared/GameTicking/SharedGameTicker.cs index a18036d038..9b26cc8052 100644 --- a/Content.Shared/GameTicking/SharedGameTicker.cs +++ b/Content.Shared/GameTicking/SharedGameTicker.cs @@ -139,6 +139,7 @@ namespace Content.Shared.GameTicking public int PlayerCount { get; } public RoundEndPlayerInfo[] AllPlayersEndInfo { get; } public string? LobbySong; + public string? RestartSound; public RoundEndMessageEvent( string gamemodeTitle, @@ -147,7 +148,8 @@ namespace Content.Shared.GameTicking int roundId, int playerCount, RoundEndPlayerInfo[] allPlayersEndInfo, - string? lobbySong) + string? lobbySong, + string? restartSound) { GamemodeTitle = gamemodeTitle; RoundEndText = roundEndText; @@ -156,6 +158,7 @@ namespace Content.Shared.GameTicking PlayerCount = playerCount; AllPlayersEndInfo = allPlayersEndInfo; LobbySong = lobbySong; + RestartSound = restartSound; } }