using Content.Client.GameTicking.Managers;
using Content.Client.Lobby;
using Content.Shared.CCVar;
+using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Client;
using Robust.Client.State;
_client.PlayerLeaveServer += OnLeave;
_gameTicker.LobbySongUpdated += LobbySongUpdated;
+
+ SubscribeNetworkEvent<RoundRestartCleanupEvent>(PlayRestartSound);
}
public override void Shutdown()
{
LobbyStream = _audio.Stop(LobbyStream);
}
+
+ private void PlayRestartSound(RoundRestartCleanupEvent ev)
+ {
+ if (!_configManager.GetCVar(CCVars.LobbyMusicEnabled))
+ return;
+
+ var file = _gameTicker.RestartSound;
+ if (string.IsNullOrEmpty(file))
+ {
+ return;
+ }
+
+ var volume = _lobbyParams.WithVolume(_lobbyParams.Volume +
+ SharedAudioSystem.GainToVolume(
+ _configManager.GetCVar(CCVars.LobbyMusicVolume)));
+
+ _audio.PlayGlobal(file, Filter.Local(), false, volume);
+ }
}
[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; }
{
// Force an update in the event of this song being the same as the last.
SetLobbySong(message.LobbySong, true);
+ RestartSound = message.RestartSound;
// Don't open duplicate windows (mainly for replays).
if (_window?.RoundId == message.RoundId)
// This ordering mechanism isn't great (no ordering of minds) but functions
var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray();
+ var sound = _audio.GetSound(new SoundCollectionSpecifier("RoundEnd"));
RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId,
- listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong));
+ listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong, sound));
}
private async void SendRoundEndDiscordMessage()
public int PlayerCount { get; }
public RoundEndPlayerInfo[] AllPlayersEndInfo { get; }
public string? LobbySong;
+
+ /// <summary>
+ /// Sound gets networked due to how entity lifecycle works between client / server and to avoid clipping.
+ /// </summary>
public string? RestartSound;
public RoundEndMessageEvent(
int roundId,
int playerCount,
RoundEndPlayerInfo[] allPlayersEndInfo,
- string? lobbySong)
+ string? lobbySong,
+ string? restartSound)
{
GamemodeTitle = gamemodeTitle;
RoundEndText = roundEndText;
PlayerCount = playerCount;
AllPlayersEndInfo = allPlayersEndInfo;
LobbySong = lobbySong;
+ RestartSound = restartSound;
}
}