mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
111 lines
3.7 KiB
C#
111 lines
3.7 KiB
C#
using System.Linq;
|
|
using Content.Server.GameTicking;
|
|
using Content.Server.GameTicking.Events;
|
|
using Content.Shared.Audio;
|
|
using Content.Shared.Audio.Events;
|
|
using Content.Shared.CCVar;
|
|
using Content.Shared.GameTicking;
|
|
using Content.Shared.GameTicking.Events;
|
|
using Robust.Server.Audio;
|
|
using Robust.Shared.Audio;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Random;
|
|
|
|
|
|
namespace Content.Server.Audio;
|
|
|
|
public sealed partial class ContentAudioSystem : SharedContentAudioSystem
|
|
{
|
|
[Dependency] private AudioSystem _serverAudio = default!;
|
|
[Dependency] private IRobustRandom _robustRandom = default!;
|
|
[Dependency] private IConfigurationManager _cfg = default!;
|
|
|
|
private SoundCollectionPrototype? _lobbyMusicCollection = default!;
|
|
private string[]? _lobbyPlaylist;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
//changes the music collection and reshuffles the playlist to update the lobby music
|
|
Subs.CVar(
|
|
_cfg,
|
|
CCVars.LobbyMusicCollection,
|
|
x =>
|
|
{
|
|
//Checks to see if the sound collection exists. If it does change it if not defaults to null
|
|
// as the new _lobbyMusicCollection meaning it wont play anything in the lobby.
|
|
if(ProtoMan.TryIndex<SoundCollectionPrototype>(x, out var outputSoundCollection))
|
|
{
|
|
_lobbyMusicCollection = outputSoundCollection;
|
|
}
|
|
else
|
|
{
|
|
Log.Error($"Invalid Lobby Music sound collection specified: {x}");
|
|
_lobbyMusicCollection = null;
|
|
}
|
|
|
|
_lobbyPlaylist = ShuffleLobbyPlaylist();
|
|
},
|
|
true);
|
|
|
|
SubscribeLocalEvent<RoundEndMessageEvent>(OnRoundEnd);
|
|
SubscribeLocalEvent<PlayerJoinedLobbyEvent>(OnPlayerJoinedLobby);
|
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundCleanup);
|
|
SubscribeLocalEvent<RoundStartingEvent>(OnRoundStart);
|
|
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnProtoReload);
|
|
}
|
|
|
|
private void OnRoundCleanup(RoundRestartCleanupEvent ev)
|
|
{
|
|
SilenceAudio();
|
|
}
|
|
|
|
private void OnProtoReload(PrototypesReloadedEventArgs obj)
|
|
{
|
|
if (obj.WasModified<AudioPresetPrototype>())
|
|
_serverAudio.ReloadPresets();
|
|
}
|
|
|
|
private void OnRoundStart(RoundStartingEvent ev)
|
|
{
|
|
// On cleanup all entities get purged so need to ensure audio presets are still loaded
|
|
// yeah it's whacky af.
|
|
_serverAudio.ReloadPresets();
|
|
}
|
|
|
|
private void OnPlayerJoinedLobby(PlayerJoinedLobbyEvent ev)
|
|
{
|
|
if (_lobbyPlaylist != null)
|
|
{
|
|
var session = ev.PlayerSession;
|
|
RaiseNetworkEvent(new LobbyPlaylistChangedEvent(_lobbyPlaylist), session);
|
|
}
|
|
}
|
|
|
|
private void OnRoundEnd(RoundEndMessageEvent ev)
|
|
{
|
|
// The lobby song is set here instead of in RestartRound,
|
|
// because ShowRoundEndScoreboard triggers the start of the music playing
|
|
// at the end of a round, and this needs to be set before RestartRound
|
|
// in order for the lobby song status display to be accurate.
|
|
_lobbyPlaylist = ShuffleLobbyPlaylist();
|
|
RaiseNetworkEvent(new LobbyPlaylistChangedEvent(_lobbyPlaylist));
|
|
}
|
|
|
|
private string[] ShuffleLobbyPlaylist()
|
|
{
|
|
if (_lobbyMusicCollection == null)
|
|
{
|
|
return [];
|
|
}
|
|
|
|
var playlist = _lobbyMusicCollection.PickFiles
|
|
.Select(x => x.ToString())
|
|
.ToArray();
|
|
_robustRandom.Shuffle(playlist);
|
|
|
|
return playlist;
|
|
}
|
|
}
|