Merge remote-tracking branch 'upstream/stable' into ed-08-07-2025-upstream
# Conflicts: # Content.Server/Audio/ContentAudioSystem.cs # Content.Server/Medical/HealthAnalyzerSystem.cs # Content.Server/Shuttles/Systems/ShuttleSystem.cs # Resources/Locale/en-US/navmap-beacons/station-beacons.ftl
This commit is contained in:
@@ -3,12 +3,15 @@ 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 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 class ContentAudioSystem : SharedContentAudioSystem
|
||||
@@ -19,16 +22,36 @@ public sealed class ContentAudioSystem : SharedContentAudioSystem
|
||||
[Dependency] private readonly AudioSystem _serverAudio = default!;
|
||||
[Dependency] private readonly IRobustRandom _robustRandom = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
private SoundCollectionPrototype _lobbyMusicCollection = default!;
|
||||
private SoundCollectionPrototype? _lobbyMusicCollection = default!;
|
||||
private string[]? _lobbyPlaylist;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
_lobbyMusicCollection = _prototypeManager.Index<SoundCollectionPrototype>(LobbyMusicCollection);
|
||||
_lobbyPlaylist = ShuffleLobbyPlaylist();
|
||||
//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(_prototypeManager.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);
|
||||
@@ -76,11 +99,16 @@ public sealed class ContentAudioSystem : SharedContentAudioSystem
|
||||
|
||||
private string[] ShuffleLobbyPlaylist()
|
||||
{
|
||||
if (_lobbyMusicCollection == null)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var playlist = _lobbyMusicCollection.PickFiles
|
||||
.Select(x => x.ToString())
|
||||
.ToArray();
|
||||
_robustRandom.Shuffle(playlist);
|
||||
_robustRandom.Shuffle(playlist);
|
||||
|
||||
return playlist;
|
||||
return playlist;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user