Skip to content

Commit

Permalink
Update to Robust Toolbox audio changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sowelipililimute committed Nov 28, 2024
1 parent 1bc6562 commit 2c635df
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 28 deletions.
6 changes: 3 additions & 3 deletions Content.Client/Audio/ClientGlobalSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void PlayAdminSound(AdminSoundEvent soundEvent)
{
if(!_adminAudioEnabled) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Specifier, Filter.Local(), false, soundEvent.AudioParams);
_adminAudio.Add(stream?.Entity);
}

Expand All @@ -75,13 +75,13 @@ private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
// Either the cvar is disabled or it's already playing
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Specifier, Filter.Local(), false, soundEvent.AudioParams);
_eventAudio.Add(soundEvent.Type, stream?.Entity);
}

private void PlayGameSound(GameGlobalSoundEvent soundEvent)
{
_audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_audio.PlayGlobal(soundEvent.Specifier, Filter.Local(), false, soundEvent.AudioParams);
}

private void StopStationEventMusic(StopStationEventMusic soundEvent)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private void PlayRestartSound(RoundRestartCleanupEvent ev)
return;

var file = _gameTicker.RestartSound;
if (string.IsNullOrEmpty(file))
if (ResolvedSoundSpecifier.IsNullOrEmpty(file))
{
return;
}
Expand Down
3 changes: 2 additions & 1 deletion Content.Client/GameTicking/Managers/ClientGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Shared.Prototypes;
using Robust.Shared.Audio;

namespace Content.Client.GameTicking.Managers
{
Expand All @@ -26,7 +27,7 @@ public sealed class ClientGameTicker : SharedGameTicker

[ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? RestartSound { get; private set; }
[ViewVariables] public ResolvedSoundSpecifier? 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; }
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Guidebook/GuidebookSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private void OnGuidebookControlsTestInteractHand(EntityUid uid, GuidebookControl
if (!TryComp<SpeechComponent>(uid, out var speech) || speech.SpeechSounds is null)
return;

_audioSystem.PlayGlobal(speech.SpeechSounds, Filter.Local(), false, speech.AudioParams);
// _audioSystem.PlayGlobal(speech.SpeechSounds, Filter.Local(), false, speech.AudioParams);
}

public void FakeClientActivateInWorld(EntityUid activated)
Expand Down
12 changes: 6 additions & 6 deletions Content.Server/Audio/ServerGlobalSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public override void Shutdown()
_conHost.UnregisterCommand("playglobalsound");
}

public void PlayAdminGlobal(Filter playerFilter, string filename, AudioParams? audioParams = null, bool replay = true)
public void PlayAdminGlobal(Filter playerFilter, ResolvedSoundSpecifier specifier, AudioParams? audioParams = null, bool replay = true)
{
var msg = new AdminSoundEvent(filename, audioParams);
var msg = new AdminSoundEvent(specifier, audioParams);
RaiseNetworkEvent(msg, playerFilter, recordReplay: replay);
}

Expand All @@ -32,9 +32,9 @@ private Filter GetStationAndPvs(EntityUid source)
return stationFilter;
}

public void PlayGlobalOnStation(EntityUid source, string filename, AudioParams? audioParams = null)
public void PlayGlobalOnStation(EntityUid source, ResolvedSoundSpecifier specifier, AudioParams? audioParams = null)
{
var msg = new GameGlobalSoundEvent(filename, audioParams);
var msg = new GameGlobalSoundEvent(specifier, audioParams);
var filter = GetStationAndPvs(source);
RaiseNetworkEvent(msg, filter);
}
Expand All @@ -55,10 +55,10 @@ public void DispatchStationEventMusic(EntityUid source, SoundSpecifier sound, St
DispatchStationEventMusic(source, _audio.GetSound(sound), type);
}

public void DispatchStationEventMusic(EntityUid source, string sound, StationEventMusicType type)
public void DispatchStationEventMusic(EntityUid source, ResolvedSoundSpecifier specifier, StationEventMusicType type)
{
var audio = AudioParams.Default.WithVolume(-8);
var msg = new StationEventMusicEvent(sound, type, audio);
var msg = new StationEventMusicEvent(specifier, type, audio);

var filter = GetStationAndPvs(source);
RaiseNetworkEvent(msg, filter);
Expand Down
4 changes: 2 additions & 2 deletions Content.Server/Nuke/NukeSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public sealed class NukeSystem : EntitySystem
/// Used to calculate when the nuke song should start playing for maximum kino with the nuke sfx
/// </summary>
private float _nukeSongLength;
private string _selectedNukeSong = String.Empty;
private ResolvedSoundSpecifier _selectedNukeSong = String.Empty;

/// <summary>
/// Time to leave between the nuke song and the nuke alarm playing.
Expand Down Expand Up @@ -301,7 +301,7 @@ private void TickTimer(EntityUid uid, float frameTime, NukeComponent? nuke = nul

// Start playing the nuke event song so that it ends a couple seconds before the alert sound
// should play
if (nuke.RemainingTime <= _nukeSongLength + nuke.AlertSoundTime + NukeSongBuffer && !nuke.PlayedNukeSong && !string.IsNullOrEmpty(_selectedNukeSong))
if (nuke.RemainingTime <= _nukeSongLength + nuke.AlertSoundTime + NukeSongBuffer && !nuke.PlayedNukeSong && !ResolvedSoundSpecifier.IsNullOrEmpty(_selectedNukeSong))
{
_sound.DispatchStationEventMusic(uid, _selectedNukeSong, StationEventMusicType.Nuke);
nuke.PlayedNukeSong = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,5 @@ public sealed partial class SalvageExpeditionComponent : SharedSalvageExpedition
/// Song selected on MapInit so we can predict the audio countdown properly.
/// </summary>
[DataField]
public SoundPathSpecifier SelectedSong;
public ResolvedSoundSpecifier SelectedSong;
}
3 changes: 1 addition & 2 deletions Content.Server/Salvage/SalvageSystem.Expeditions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ private void SetCooldownChange(float obj)

private void OnExpeditionMapInit(EntityUid uid, SalvageExpeditionComponent component, MapInitEvent args)
{
var selectedFile = _audio.GetSound(component.Sound);
component.SelectedSong = new SoundPathSpecifier(selectedFile, component.Sound.Params);
component.SelectedSong = _audio.GetSound(component.Sound);
}

private void OnExpeditionShutdown(EntityUid uid, SalvageExpeditionComponent component, ComponentShutdown args)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Salvage/SalvageSystem.Runner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ private void UpdateRunner()
while (query.MoveNext(out var uid, out var comp))
{
var remaining = comp.EndTime - _timing.CurTime;
var audioLength = _audio.GetAudioLength(comp.SelectedSong.Path.ToString());
var audioLength = _audio.GetAudioLength(comp.SelectedSong);

if (comp.Stage < ExpeditionStage.FinalCountdown && remaining < TimeSpan.FromSeconds(45))
{
Expand Down
14 changes: 7 additions & 7 deletions Content.Shared/Audio/SharedGlobalSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ public abstract class SharedGlobalSoundSystem : EntitySystem
[Serializable, NetSerializable]
public class GlobalSoundEvent : EntityEventArgs
{
public string Filename;
public ResolvedSoundSpecifier Specifier;
public AudioParams? AudioParams;
public GlobalSoundEvent(string filename, AudioParams? audioParams = null)
public GlobalSoundEvent(ResolvedSoundSpecifier specifier, AudioParams? audioParams = null)
{
Filename = filename;
Specifier = specifier;
AudioParams = audioParams;
}
}
Expand All @@ -29,7 +29,7 @@ public GlobalSoundEvent(string filename, AudioParams? audioParams = null)
[Serializable, NetSerializable]
public sealed class AdminSoundEvent : GlobalSoundEvent
{
public AdminSoundEvent(string filename, AudioParams? audioParams = null) : base(filename, audioParams){}
public AdminSoundEvent(ResolvedSoundSpecifier specifier, AudioParams? audioParams = null) : base(specifier, audioParams){}
}

/// <summary>
Expand All @@ -38,7 +38,7 @@ public AdminSoundEvent(string filename, AudioParams? audioParams = null) : base(
[Serializable, NetSerializable]
public sealed class GameGlobalSoundEvent : GlobalSoundEvent
{
public GameGlobalSoundEvent(string filename, AudioParams? audioParams = null) : base(filename, audioParams){}
public GameGlobalSoundEvent(ResolvedSoundSpecifier specifier, AudioParams? audioParams = null) : base(specifier, audioParams){}
}

public enum StationEventMusicType : byte
Expand All @@ -54,8 +54,8 @@ public sealed class StationEventMusicEvent : GlobalSoundEvent
{
public StationEventMusicType Type;

public StationEventMusicEvent(string filename, StationEventMusicType type, AudioParams? audioParams = null) : base(
filename, audioParams)
public StationEventMusicEvent(ResolvedSoundSpecifier specifier, StationEventMusicType type, AudioParams? audioParams = null) : base(
specifier, audioParams)
{
Type = type;
}
Expand Down
5 changes: 3 additions & 2 deletions Content.Shared/GameTicking/SharedGameTicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Robust.Shared.Serialization.Markdown.Mapping;
using Robust.Shared.Serialization.Markdown.Value;
using Robust.Shared.Timing;
using Robust.Shared.Audio;

namespace Content.Shared.GameTicking
{
Expand Down Expand Up @@ -193,7 +194,7 @@ public partial struct RoundEndPlayerInfo
/// <summary>
/// Sound gets networked due to how entity lifecycle works between client / server and to avoid clipping.
/// </summary>
public string? RestartSound;
public ResolvedSoundSpecifier? RestartSound;

public RoundEndMessageEvent(
string gamemodeTitle,
Expand All @@ -202,7 +203,7 @@ public RoundEndMessageEvent(
int roundId,
int playerCount,
RoundEndPlayerInfo[] allPlayersEndInfo,
string? restartSound)
ResolvedSoundSpecifier? restartSound)
{
GamemodeTitle = gamemodeTitle;
RoundEndText = roundEndText;
Expand Down

0 comments on commit 2c635df

Please sign in to comment.