Fixes round restart audio clipping (#24044)
* Fix round end audio clipping * weh --------- Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
committed by
GitHub
parent
ed2fa96ca0
commit
5af1d0ea8b
@@ -1,6 +1,7 @@
|
|||||||
using Content.Client.GameTicking.Managers;
|
using Content.Client.GameTicking.Managers;
|
||||||
using Content.Client.Lobby;
|
using Content.Client.Lobby;
|
||||||
using Content.Shared.CCVar;
|
using Content.Shared.CCVar;
|
||||||
|
using Content.Shared.GameTicking;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client;
|
using Robust.Client;
|
||||||
using Robust.Client.State;
|
using Robust.Client.State;
|
||||||
@@ -39,6 +40,8 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
|||||||
_client.PlayerLeaveServer += OnLeave;
|
_client.PlayerLeaveServer += OnLeave;
|
||||||
|
|
||||||
_gameTicker.LobbySongUpdated += LobbySongUpdated;
|
_gameTicker.LobbySongUpdated += LobbySongUpdated;
|
||||||
|
|
||||||
|
SubscribeNetworkEvent<RoundRestartCleanupEvent>(PlayRestartSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
@@ -129,4 +132,22 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
LobbyStream = _audio.Stop(LobbyStream);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace Content.Client.GameTicking.Managers
|
|||||||
[ViewVariables] public bool AreWeReady { get; private set; }
|
[ViewVariables] public bool AreWeReady { get; private set; }
|
||||||
[ViewVariables] public bool IsGameStarted { get; private set; }
|
[ViewVariables] public bool IsGameStarted { get; private set; }
|
||||||
[ViewVariables] public string? LobbySong { 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 string? LobbyBackground { get; private set; }
|
||||||
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
|
[ViewVariables] public bool DisallowedLateJoin { get; private set; }
|
||||||
[ViewVariables] public string? ServerInfoBlob { get; private set; }
|
[ViewVariables] public string? ServerInfoBlob { get; private set; }
|
||||||
@@ -151,6 +152,7 @@ namespace Content.Client.GameTicking.Managers
|
|||||||
{
|
{
|
||||||
// Force an update in the event of this song being the same as the last.
|
// Force an update in the event of this song being the same as the last.
|
||||||
SetLobbySong(message.LobbySong, true);
|
SetLobbySong(message.LobbySong, true);
|
||||||
|
RestartSound = message.RestartSound;
|
||||||
|
|
||||||
// Don't open duplicate windows (mainly for replays).
|
// Don't open duplicate windows (mainly for replays).
|
||||||
if (_window?.RoundId == message.RoundId)
|
if (_window?.RoundId == message.RoundId)
|
||||||
|
|||||||
@@ -385,9 +385,10 @@ namespace Content.Server.GameTicking
|
|||||||
|
|
||||||
// This ordering mechanism isn't great (no ordering of minds) but functions
|
// This ordering mechanism isn't great (no ordering of minds) but functions
|
||||||
var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray();
|
var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray();
|
||||||
|
var sound = _audio.GetSound(new SoundCollectionSpecifier("RoundEnd"));
|
||||||
|
|
||||||
RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId,
|
RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId,
|
||||||
listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong));
|
listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong, sound));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void SendRoundEndDiscordMessage()
|
private async void SendRoundEndDiscordMessage()
|
||||||
|
|||||||
@@ -166,6 +166,10 @@ namespace Content.Shared.GameTicking
|
|||||||
public int PlayerCount { get; }
|
public int PlayerCount { get; }
|
||||||
public RoundEndPlayerInfo[] AllPlayersEndInfo { get; }
|
public RoundEndPlayerInfo[] AllPlayersEndInfo { get; }
|
||||||
public string? LobbySong;
|
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 string? RestartSound;
|
||||||
|
|
||||||
public RoundEndMessageEvent(
|
public RoundEndMessageEvent(
|
||||||
@@ -175,7 +179,8 @@ namespace Content.Shared.GameTicking
|
|||||||
int roundId,
|
int roundId,
|
||||||
int playerCount,
|
int playerCount,
|
||||||
RoundEndPlayerInfo[] allPlayersEndInfo,
|
RoundEndPlayerInfo[] allPlayersEndInfo,
|
||||||
string? lobbySong)
|
string? lobbySong,
|
||||||
|
string? restartSound)
|
||||||
{
|
{
|
||||||
GamemodeTitle = gamemodeTitle;
|
GamemodeTitle = gamemodeTitle;
|
||||||
RoundEndText = roundEndText;
|
RoundEndText = roundEndText;
|
||||||
@@ -184,6 +189,7 @@ namespace Content.Shared.GameTicking
|
|||||||
PlayerCount = playerCount;
|
PlayerCount = playerCount;
|
||||||
AllPlayersEndInfo = allPlayersEndInfo;
|
AllPlayersEndInfo = allPlayersEndInfo;
|
||||||
LobbySong = lobbySong;
|
LobbySong = lobbySong;
|
||||||
|
RestartSound = restartSound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user