From 1ba58456c4f8e49ac05b25f226c9a73392f098d4 Mon Sep 17 00:00:00 2001 From: 20kdc Date: Mon, 22 Nov 2021 22:34:48 +0000 Subject: [PATCH] Announcements play the general announcement sound unless specifically inhibited (#5460) --- Content.Server/Announcements/AnnounceCommand.cs | 13 ++++++------- Content.Server/Chat/Managers/ChatManager.cs | 8 +++++++- Content.Server/Chat/Managers/IChatManager.cs | 3 ++- .../CommunicationsConsoleComponent.cs | 2 -- Content.Server/GameTicking/GameTicker.Spawning.cs | 3 ++- Content.Server/Nuke/NukeSystem.cs | 4 ++-- Content.Server/Roles/Job.cs | 2 +- Content.Server/RoundEnd/RoundEndSystem.cs | 4 ++-- Content.Server/StationEvents/Events/StationEvent.cs | 4 ++-- 9 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Content.Server/Announcements/AnnounceCommand.cs b/Content.Server/Announcements/AnnounceCommand.cs index 0da2ad6d19..40e08df1f2 100644 --- a/Content.Server/Announcements/AnnounceCommand.cs +++ b/Content.Server/Announcements/AnnounceCommand.cs @@ -4,6 +4,7 @@ using Content.Server.Chat.Managers; using Content.Shared.Administration; using Robust.Shared.Console; using Robust.Shared.IoC; +using Robust.Shared.Audio; namespace Content.Server.Announcements { @@ -26,14 +27,12 @@ namespace Content.Server.Announcements if (args.Length == 1) { chat.DispatchStationAnnouncement(args[0]); - shell.WriteLine("Sent!"); - return; } - - if (args.Length < 2) return; - - var message = string.Join(' ', new ArraySegment(args, 1, args.Length-1)); - chat.DispatchStationAnnouncement(message, args[0]); + else + { + var message = string.Join(' ', new ArraySegment(args, 1, args.Length-1)); + chat.DispatchStationAnnouncement(message, args[0]); + } shell.WriteLine("Sent!"); } } diff --git a/Content.Server/Chat/Managers/ChatManager.cs b/Content.Server/Chat/Managers/ChatManager.cs index 8d1a8b7609..01612ba2e0 100644 --- a/Content.Server/Chat/Managers/ChatManager.cs +++ b/Content.Server/Chat/Managers/ChatManager.cs @@ -16,12 +16,14 @@ using Content.Shared.Inventory; using Content.Shared.Popups; using Robust.Server.GameObjects; using Robust.Server.Player; +using Robust.Shared.Audio; using Robust.Shared.Configuration; using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Log; using Robust.Shared.Network; +using Robust.Shared.Player; using Robust.Shared.Utility; using static Content.Server.Chat.Managers.IChatManager; @@ -90,13 +92,17 @@ namespace Content.Server.Chat.Managers Logger.InfoS("SERVER", message); } - public void DispatchStationAnnouncement(string message, string sender = "CentComm") + public void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true) { var msg = _netManager.CreateNetMessage(); msg.Channel = ChatChannel.Radio; msg.Message = message; msg.MessageWrap = Loc.GetString("chat-manager-sender-announcement-wrap-message", ("sender", sender)); _netManager.ServerSendToAll(msg); + if (playDefaultSound) + { + SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/announce.ogg", AudioParams.Default.WithVolume(-2f)); + } } public void DispatchServerMessage(IPlayerSession player, string message) diff --git a/Content.Server/Chat/Managers/IChatManager.cs b/Content.Server/Chat/Managers/IChatManager.cs index 79f6c99dff..28c1aec2b9 100644 --- a/Content.Server/Chat/Managers/IChatManager.cs +++ b/Content.Server/Chat/Managers/IChatManager.cs @@ -17,7 +17,8 @@ namespace Content.Server.Chat.Managers /// /// /// - void DispatchStationAnnouncement(string message, string sender = "CentComm"); + /// If the default 'PA' sound should be played. + void DispatchStationAnnouncement(string message, string sender = "CentComm", bool playDefaultSound = true); void DispatchServerMessage(IPlayerSession player, string message); diff --git a/Content.Server/Communications/CommunicationsConsoleComponent.cs b/Content.Server/Communications/CommunicationsConsoleComponent.cs index 3667f134fb..cfd856c99b 100644 --- a/Content.Server/Communications/CommunicationsConsoleComponent.cs +++ b/Content.Server/Communications/CommunicationsConsoleComponent.cs @@ -116,8 +116,6 @@ namespace Content.Server.Communications author = $"{id.FullName} ({CultureInfo.CurrentCulture.TextInfo.ToTitleCase(id.JobTitle ?? string.Empty)})".Trim(); } - SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/announce.ogg", AudioParams.Default.WithVolume(-2f)); - message += $"\nSent by {author}"; _chatManager.DispatchStationAnnouncement(message, "Communications Console"); break; diff --git a/Content.Server/GameTicking/GameTicker.Spawning.cs b/Content.Server/GameTicking/GameTicker.Spawning.cs index f8901a95af..f85d20dd3c 100644 --- a/Content.Server/GameTicking/GameTicker.Spawning.cs +++ b/Content.Server/GameTicking/GameTicker.Spawning.cs @@ -90,7 +90,8 @@ namespace Content.Server.GameTicking "latejoin-arrival-announcement", ("character", character.Name), ("job", CultureInfo.CurrentCulture.TextInfo.ToTitleCase(job.Name)) - ), Loc.GetString("latejoin-arrival-sender")); + ), Loc.GetString("latejoin-arrival-sender"), + playDefaultSound: false); } var mob = SpawnPlayerMob(job, character, lateJoin); diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 58e6571ce8..865c644902 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -346,7 +346,7 @@ namespace Content.Server.Nuke var announcement = Loc.GetString("nuke-component-announcement-armed", ("time", (int) component.RemainingTime)); var sender = Loc.GetString("nuke-component-announcement-sender"); - _chat.DispatchStationAnnouncement(announcement, sender); + _chat.DispatchStationAnnouncement(announcement, sender, false); // todo: move it to announcements system SoundSystem.Play(Filter.Broadcast(), component.ArmSound.GetSound()); @@ -370,7 +370,7 @@ namespace Content.Server.Nuke // warn a crew var announcement = Loc.GetString("nuke-component-announcement-unarmed"); var sender = Loc.GetString("nuke-component-announcement-sender"); - _chat.DispatchStationAnnouncement(announcement, sender); + _chat.DispatchStationAnnouncement(announcement, sender, false); // todo: move it to announcements system SoundSystem.Play(Filter.Broadcast(), component.DisarmSound.GetSound()); diff --git a/Content.Server/Roles/Job.cs b/Content.Server/Roles/Job.cs index df32c69dbe..658ecf748f 100644 --- a/Content.Server/Roles/Job.cs +++ b/Content.Server/Roles/Job.cs @@ -39,7 +39,7 @@ namespace Content.Server.Roles if(Prototype.JoinNotifyCrew && Mind.CharacterName != null) chat.DispatchStationAnnouncement(Loc.GetString("job-greet-join-notify-crew", ("jobName", Name), ("characterName", Mind.CharacterName)), - Loc.GetString("job-greet-join-notify-crew-announcer")); + Loc.GetString("job-greet-join-notify-crew-announcer"), false); } } } diff --git a/Content.Server/RoundEnd/RoundEndSystem.cs b/Content.Server/RoundEnd/RoundEndSystem.cs index bc8a6031bf..b33872e2c0 100644 --- a/Content.Server/RoundEnd/RoundEndSystem.cs +++ b/Content.Server/RoundEnd/RoundEndSystem.cs @@ -105,7 +105,7 @@ namespace Content.Server.RoundEnd IsRoundEndCountdownStarted = true; - _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station")); + _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-called-announcement",("minutes", countdownTime.Minutes)), Loc.GetString("Station"), false); SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlecalled.ogg"); @@ -138,7 +138,7 @@ namespace Content.Server.RoundEnd IsRoundEndCountdownStarted = false; - _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-recalled-announcement"), Loc.GetString("Station")); + _chatManager.DispatchStationAnnouncement(Loc.GetString("round-end-system-shuttle-recalled-announcement"), Loc.GetString("Station"), false); SoundSystem.Play(Filter.Broadcast(), "/Audio/Announcements/shuttlerecalled.ogg"); diff --git a/Content.Server/StationEvents/Events/StationEvent.cs b/Content.Server/StationEvents/Events/StationEvent.cs index 234308ac39..c454cc0d5c 100644 --- a/Content.Server/StationEvents/Events/StationEvent.cs +++ b/Content.Server/StationEvents/Events/StationEvent.cs @@ -123,7 +123,7 @@ namespace Content.Server.StationEvents.Events if (StartAnnouncement != null) { var chatManager = IoCManager.Resolve(); - chatManager.DispatchStationAnnouncement(StartAnnouncement); + chatManager.DispatchStationAnnouncement(StartAnnouncement, playDefaultSound: false); } if (StartAudio != null) @@ -146,7 +146,7 @@ namespace Content.Server.StationEvents.Events if (EndAnnouncement != null) { var chatManager = IoCManager.Resolve(); - chatManager.DispatchStationAnnouncement(EndAnnouncement); + chatManager.DispatchStationAnnouncement(EndAnnouncement, playDefaultSound: false); } if (EndAudio != null)