From 8f4ba76d8a8cdc5cb52a7c1160550b120919aa39 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Fri, 3 Nov 2023 23:02:17 -0700 Subject: [PATCH] shuttle, comms, and roundstart announcements --- .../CommunicationsConsoleSystem.cs | 9 ++++-- .../GameTicking/GameTicker.RoundFlow.cs | 9 +++--- Content.Server/RoundEnd/RoundEndSystem.cs | 28 +++++++++++-------- .../Systems/EmergencyShuttleSystem.Console.cs | 20 +++++-------- .../Systems/EmergencyShuttleSystem.cs | 16 +++++------ 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Content.Server/Communications/CommunicationsConsoleSystem.cs b/Content.Server/Communications/CommunicationsConsoleSystem.cs index b2945c2a11..8361f310c3 100644 --- a/Content.Server/Communications/CommunicationsConsoleSystem.cs +++ b/Content.Server/Communications/CommunicationsConsoleSystem.cs @@ -7,6 +7,8 @@ using Content.Server.Popups; using Content.Server.RoundEnd; using Content.Server.Shuttles.Systems; +using Content.Server.SimpleStation14.Announcements.Systems; +using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Access.Components; using Content.Shared.Access.Systems; @@ -17,6 +19,7 @@ using Content.Shared.Popups; using Robust.Server.GameObjects; using Robust.Shared.Configuration; +using Robust.Shared.Player; namespace Content.Server.Communications { @@ -34,6 +37,7 @@ public sealed class CommunicationsConsoleSystem : EntitySystem [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; // Parkstation-RandomAnnouncer private const int MaxMessageLength = 256; private const int MaxMessageNewlines = 2; @@ -272,14 +276,15 @@ private void OnAnnounceMessage(EntityUid uid, CommunicationsConsoleComponent com msg += "\n" + Loc.GetString("comms-console-announcement-sent-by") + " " + author; if (comp.Global) { - _chatSystem.DispatchGlobalAnnouncement(msg, title, announcementSound: comp.Sound, colorOverride: comp.Color); + _announcer.SendAnnouncement("announce", Filter.Broadcast(), msg, title, comp.Color); // Parkstation-RandomAnnouncer if (message.Session.AttachedEntity != null) _adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following global announcement: {msg}"); return; } - _chatSystem.DispatchStationAnnouncement(uid, msg, title, colorOverride: comp.Color); + if (TryComp(_stationSystem.GetOwningStation(uid), out var stationData)) // Parkstation-RandomAnnouncer + _announcer.SendAnnouncement("announce", _stationSystem.GetInStation(stationData), msg, title, comp.Color); if (message.Session.AttachedEntity != null) _adminLogger.Add(LogType.Chat, LogImpact.Low, $"{ToPrettyString(message.Session.AttachedEntity.Value):player} has sent the following station announcement: {msg}"); diff --git a/Content.Server/GameTicking/GameTicker.RoundFlow.cs b/Content.Server/GameTicking/GameTicker.RoundFlow.cs index a10196a43e..488c061fe1 100644 --- a/Content.Server/GameTicking/GameTicker.RoundFlow.cs +++ b/Content.Server/GameTicking/GameTicker.RoundFlow.cs @@ -4,6 +4,7 @@ using Content.Server.GameTicking.Events; using Content.Server.Ghost; using Content.Server.Maps; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Shared.Database; using Content.Shared.GameTicking; using Content.Shared.Mind; @@ -27,6 +28,7 @@ public sealed partial class GameTicker { [Dependency] private readonly DiscordWebhook _discord = default!; [Dependency] private readonly ITaskManager _taskManager = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; private static readonly Counter RoundNumberMetric = Metrics.CreateCounter( "ss14_round_number", @@ -606,11 +608,8 @@ private void AnnounceRound() var proto = _robustRandom.Pick(options); - if (proto.Message != null) - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(proto.Message), playSound: true); - - if (proto.Sound != null) - SoundSystem.Play(proto.Sound.GetSound(), Filter.Broadcast()); + if (proto.Message != null) // Parkstation-RandomAnnouncer + _announcer.SendAnnouncement("welcome", Filter.Broadcast(), Loc.GetString(proto.Message)); } private async void SendRoundStartedDiscordMessage() diff --git a/Content.Server/RoundEnd/RoundEndSystem.cs b/Content.Server/RoundEnd/RoundEndSystem.cs index 6043f3fbf9..1b4cb2be76 100644 --- a/Content.Server/RoundEnd/RoundEndSystem.cs +++ b/Content.Server/RoundEnd/RoundEndSystem.cs @@ -7,6 +7,7 @@ using Content.Server.Chat.Systems; using Content.Server.GameTicking; using Content.Server.Shuttles.Systems; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Station.Systems; using Content.Shared.Database; using Content.Shared.GameTicking; @@ -34,6 +35,7 @@ public sealed class RoundEndSystem : EntitySystem [Dependency] private readonly GameTicker _gameTicker = default!; [Dependency] private readonly EmergencyShuttleSystem _shuttle = default!; [Dependency] private readonly StationSystem _stationSystem = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; public TimeSpan DefaultCooldownDuration { get; set; } = TimeSpan.FromSeconds(30); @@ -146,15 +148,15 @@ public void RequestRoundEnd(TimeSpan countdownTime, EntityUid? requester = null, units = "eta-units-minutes"; } - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(text, - ("time", time), - ("units", Loc.GetString(units))), + _announcer.SendAnnouncement("shuttlecalled", // Parkstation-RandomAnnouncers + Filter.Broadcast(), + Loc.GetString(text, + ("time", time), + ("units", Loc.GetString(units)) + ), name, - false, - null, - Color.Gold); - - SoundSystem.Play("/Audio/Announcements/shuttlecalled.ogg", Filter.Broadcast()); + Color.Gold + ); LastCountdownStart = _gameTiming.CurTime; ExpectedCountdownEnd = _gameTiming.CurTime + countdownTime; @@ -182,10 +184,12 @@ public void CancelRoundEndCountdown(EntityUid? requester = null, bool checkCoold _adminLogger.Add(LogType.ShuttleRecalled, LogImpact.High, $"Shuttle recalled"); } - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("round-end-system-shuttle-recalled-announcement"), - Loc.GetString("Station"), false, colorOverride: Color.Gold); - - SoundSystem.Play("/Audio/Announcements/shuttlerecalled.ogg", Filter.Broadcast()); + _announcer.SendAnnouncement("shuttlerecalled", // Parkstation-RandomAnnouncers + Filter.Broadcast(), + Loc.GetString("round-end-system-shuttle-recalled-announcement"), + Loc.GetString("Station"), + Color.Gold + ); LastCountdownStart = null; ExpectedCountdownEnd = null; diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs index deb2ba256d..53cf79fdbb 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.Console.cs @@ -221,7 +221,7 @@ private void UpdateEmergencyConsole(float frameTime) if (!ShuttlesLeft && _consoleAccumulator <= 0f) { ShuttlesLeft = true; - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}"))); + _announcer.SendAnnouncement("shuttleleft", Filter.Broadcast(), Loc.GetString("emergency-shuttle-left", ("transitTime", $"{TransitTime:0}"))); // Parkstation-RandomAnnouncer Timer.Spawn((int) (TransitTime * 1000) + _bufferTime.Milliseconds, () => _roundEnd.EndRound(), _roundEndCancelToken?.Token ?? default); } @@ -257,7 +257,7 @@ private void OnEmergencyRepealAll(EntityUid uid, EmergencyShuttleConsoleComponen return; _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch REPEAL ALL by {args.Session:user}"); - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-console-auth-revoked", ("remaining", component.AuthorizationsRequired))); + _announcer.SendAnnouncement("shuttleauthrevoked", Filter.Broadcast(), Loc.GetString("emergency-shuttle-console-auth-revoked", ("remaining", component.AuthorizationsRequired))); // Parkstation-RandomAnnouncer component.AuthorizedEntities.Clear(); UpdateAllEmergencyConsoles(); } @@ -280,7 +280,7 @@ private void OnEmergencyRepeal(EntityUid uid, EmergencyShuttleConsoleComponent c _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle early launch REPEAL by {args.Session:user}"); var remaining = component.AuthorizationsRequired - component.AuthorizedEntities.Count; - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString("emergency-shuttle-console-auth-revoked", ("remaining", remaining))); + _announcer.SendAnnouncement("shuttleauthrevoked", Filter.Broadcast(), Loc.GetString("emergency-shuttle-console-auth-revoked", ("remaining", remaining))); // Parkstation-RandomAnnouncer CheckForLaunch(component); UpdateAllEmergencyConsoles(); } @@ -305,12 +305,11 @@ private void OnEmergencyAuthorize(EntityUid uid, EmergencyShuttleConsoleComponen var remaining = component.AuthorizationsRequired - component.AuthorizedEntities.Count; if (remaining > 0) - _chatSystem.DispatchGlobalAnnouncement( + _announcer.SendAnnouncement("shuttleauthadded", // Parkstation-RandomAnnouncer + Filter.Broadcast(), Loc.GetString("emergency-shuttle-console-auth-left", ("remaining", remaining)), - playSound: false, colorOverride: DangerColor); + colorOverride: DangerColor); - if (!CheckForLaunch(component)) - _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), recordReplay: true); UpdateAllEmergencyConsoles(); } @@ -389,12 +388,7 @@ private void AnnounceLaunch() if (_announced) return; _announced = true; - _chatSystem.DispatchGlobalAnnouncement( - Loc.GetString("emergency-shuttle-launch-time", ("consoleAccumulator", $"{_consoleAccumulator:0}")), - playSound: false, - colorOverride: DangerColor); - - _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), recordReplay: true); + _announcer.SendAnnouncement("shuttlealmostlaunching", Filter.Broadcast(), Loc.GetString("emergency-shuttle-launch-time", ("consoleAccumulator", $"{_consoleAccumulator:0}"))); // Parkstation-RandomAnnouncer } public bool DelayEmergencyRoundEnd() diff --git a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs index 1a1debc9e3..26843ffb3d 100644 --- a/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs @@ -9,6 +9,7 @@ using Content.Server.Popups; using Content.Server.RoundEnd; using Content.Server.Shuttles.Components; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Access.Systems; @@ -54,6 +55,7 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem [Dependency] private readonly ShuttleSystem _shuttle = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; private ISawmill _sawmill = default!; @@ -188,9 +190,7 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo if (targetGrid == null) { _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid)} unable to dock with station {ToPrettyString(stationUid)}"); - _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-good-luck"), playDefaultSound: false); - // TODO: Need filter extensions or something don't blame me. - _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); + _announcer.SendAnnouncement("shuttlegoodluck", Filter.Broadcast(), Loc.GetString("emergency-shuttle-good-luck"), colorOverride: DangerColor); return; } @@ -201,24 +201,22 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo if (TryComp(targetGrid.Value, out var targetXform)) { var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery); - _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", angle.GetDir())), playDefaultSound: false); + _announcer.SendAnnouncementMessage("shuttledock", Loc.GetString("emergency-shuttle-docked", ("time", $"{_consoleAccumulator:0}"), ("direction", angle.GetDir()))); // Parkstation-RandomAnnouncer } _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid)} docked with stations"); - // TODO: Need filter extensions or something don't blame me. - _audio.PlayGlobal("/Audio/Announcements/shuttle_dock.ogg", Filter.Broadcast(), true); + _announcer.SendAnnouncementAudio("shuttledock", Filter.Broadcast()); // Parkstation-RandomAnnouncer } else { if (TryComp(targetGrid.Value, out var targetXform)) { var angle = _dock.GetAngle(stationShuttle.EmergencyShuttle.Value, xform, targetGrid.Value, targetXform, xformQuery); - _chatSystem.DispatchStationAnnouncement(stationUid, Loc.GetString("emergency-shuttle-nearby", ("direction", angle.GetDir())), playDefaultSound: false); + _announcer.SendAnnouncementMessage("shuttlenearby", Loc.GetString("emergency-shuttle-nearby", ("direction", angle.GetDir()))); // Parkstation-RandomAnnouncer } _logger.Add(LogType.EmergencyShuttle, LogImpact.High, $"Emergency shuttle {ToPrettyString(stationUid)} unable to find a valid docking port for {ToPrettyString(stationUid)}"); - // TODO: Need filter extensions or something don't blame me. - _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); + _announcer.SendAnnouncementAudio("shuttlenearby", Filter.Broadcast()); // Parkstation-RandomAnnouncer } }