From 9bf9b0be0849949f2cfb4fee89867e1f71920749 Mon Sep 17 00:00:00 2001 From: DEATHB4DEFEAT Date: Sat, 17 Feb 2024 18:31:45 -0800 Subject: [PATCH] more systems use AnnouncerSystem, update template --- .../Announcements/Systems/AnnouncerSystem.cs | 2 +- Content.Server/AlertLevel/AlertLevelSystem.cs | 16 ++++------------ .../Chat/Systems/AnnounceOnSpawnSystem.cs | 5 ++++- .../Communications/CommsHackerSystem.cs | 5 ++++- Content.Server/Dragon/DragonRiftSystem.cs | 5 +++-- .../GameTicking/Rules/NukeopsRuleSystem.cs | 4 +++- .../GameTicking/Rules/ZombieRuleSystem.cs | 4 +++- Content.Server/Nuke/NukeCodePaperSystem.cs | 5 ++++- Content.Server/Nuke/NukeSystem.cs | 7 ++++--- Content.Server/PowerSink/PowerSinkSystem.cs | 9 +++------ Content.Server/RoundEnd/RoundEndSystem.cs | 7 +++++-- .../Systems/SharedAnnouncerSystem.cs | 4 ++-- .../SimpleStation14/Announcers/template | 15 ++++++++++++--- 13 files changed, 52 insertions(+), 36 deletions(-) diff --git a/Content.Client/SimpleStation14/Announcements/Systems/AnnouncerSystem.cs b/Content.Client/SimpleStation14/Announcements/Systems/AnnouncerSystem.cs index 1358052c00..07b02d9ad3 100644 --- a/Content.Client/SimpleStation14/Announcements/Systems/AnnouncerSystem.cs +++ b/Content.Client/SimpleStation14/Announcements/Systems/AnnouncerSystem.cs @@ -54,7 +54,7 @@ private void OnAnnouncementReceived(AnnouncementSendEvent ev) if (!ev.Recipients.Contains(_player.LocalSession!.UserId)) return; - var resource = _cache.GetResource(_announcer.GetAnnouncementPath(ev.AnnouncementId, ev.AnnouncerId)!); + var resource = _cache.GetResource(_announcer.GetAnnouncementPath(ev.AnnouncementId, ev.AnnouncerId)); var source = _audioManager.CreateAudioSource(resource); if (source != null) diff --git a/Content.Server/AlertLevel/AlertLevelSystem.cs b/Content.Server/AlertLevel/AlertLevelSystem.cs index 04e274ceeb..35c08cfe72 100644 --- a/Content.Server/AlertLevel/AlertLevelSystem.cs +++ b/Content.Server/AlertLevel/AlertLevelSystem.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Server.Chat.Systems; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Station.Systems; using Content.Shared.CCVar; using Robust.Shared.Audio; @@ -16,6 +17,7 @@ public sealed class AlertLevelSystem : EntitySystem [Dependency] private readonly ChatSystem _chatSystem = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly StationSystem _stationSystem = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; // Until stations are a prototype, this is how it's going to have to be. public const string DefaultAlertLevelSet = "stationAlerts"; @@ -162,24 +164,14 @@ public void SetLevel(EntityUid station, string level, bool playSound, bool annou // The full announcement to be spat out into chat. var announcementFull = Loc.GetString("alert-level-announcement", ("name", name), ("announcement", announcement)); - var playDefault = false; if (playSound) { - if (detail.Sound != null) - { - var filter = _stationSystem.GetInOwningStation(station); - _audio.PlayGlobal(detail.Sound.GetSound(), filter, true, detail.Sound.Params); - } - else - { - playDefault = true; - } + _announcer.SendAnnouncementAudio($"alert{level.ToLower()}", _stationSystem.GetInOwningStation(station)); // Parkstation-RandomAnnouncers } if (announce) { - _chatSystem.DispatchStationAnnouncement(station, announcementFull, playDefaultSound: playDefault, - colorOverride: detail.Color, sender: stationName); + _announcer.SendAnnouncementMessage($"alert{level.ToLower()}", announcementFull, colorOverride: detail.Color); } RaiseLocalEvent(new AlertLevelChangedEvent(station, level)); diff --git a/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs b/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs index 0f0365e56b..04ef64bc80 100644 --- a/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs +++ b/Content.Server/Chat/Systems/AnnounceOnSpawnSystem.cs @@ -1,10 +1,13 @@ using Content.Server.Chat; +using Content.Server.SimpleStation14.Announcements.Systems; +using Robust.Shared.Player; namespace Content.Server.Chat.Systems; public sealed class AnnounceOnSpawnSystem : EntitySystem { [Dependency] private readonly ChatSystem _chat = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; public override void Initialize() { @@ -17,6 +20,6 @@ private void OnInit(EntityUid uid, AnnounceOnSpawnComponent comp, MapInitEvent a { var message = Loc.GetString(comp.Message); var sender = comp.Sender != null ? Loc.GetString(comp.Sender) : "Central Command"; - _chat.DispatchGlobalAnnouncement(message, sender, playSound: true, comp.Sound, comp.Color); + _announcer.SendAnnouncement("spawnannounce", Filter.Broadcast(), message, sender, comp.Color); // Parkstation-RandomAnnouncers } } diff --git a/Content.Server/Communications/CommsHackerSystem.cs b/Content.Server/Communications/CommsHackerSystem.cs index 1248d21400..11426adf37 100644 --- a/Content.Server/Communications/CommsHackerSystem.cs +++ b/Content.Server/Communications/CommsHackerSystem.cs @@ -1,11 +1,13 @@ using Content.Server.Chat.Systems; using Content.Server.GameTicking; using Content.Server.Ninja.Systems; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Shared.Communications; using Content.Shared.DoAfter; using Content.Shared.Interaction; using Content.Shared.Random; using Content.Shared.Random.Helpers; +using Robust.Shared.Player; using Robust.Shared.Prototypes; using Robust.Shared.Random; using Robust.Shared.Serialization; @@ -21,6 +23,7 @@ public sealed class CommsHackerSystem : SharedCommsHackerSystem // TODO: remove when generic check event is used [Dependency] private readonly NinjaGlovesSystem _gloves = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; public override void Initialize() { @@ -79,7 +82,7 @@ private void OnDoAfter(EntityUid uid, CommsHackerComponent comp, TerrorDoAfterEv public void CallInThreat(NinjaHackingThreatPrototype ninjaHackingThreat) { _gameTicker.StartGameRule(ninjaHackingThreat.Rule, out _); - _chat.DispatchGlobalAnnouncement(Loc.GetString(ninjaHackingThreat.Announcement), playSound: true, colorOverride: Color.Red); + _announcer.SendAnnouncement("ninjahacking", Filter.Broadcast(), Loc.GetString(ninjaHackingThreat.Announcement), colorOverride: Color.Red); // Parkstation-RandomAnnouncers } } diff --git a/Content.Server/Dragon/DragonRiftSystem.cs b/Content.Server/Dragon/DragonRiftSystem.cs index f7d5cd783d..9577f4a3e2 100644 --- a/Content.Server/Dragon/DragonRiftSystem.cs +++ b/Content.Server/Dragon/DragonRiftSystem.cs @@ -11,6 +11,7 @@ using Robust.Shared.Player; using Robust.Shared.Serialization.Manager; using System.Numerics; +using Content.Server.SimpleStation14.Announcements.Systems; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; @@ -27,6 +28,7 @@ public sealed class DragonRiftSystem : EntitySystem [Dependency] private readonly NavMapSystem _navMap = default!; [Dependency] private readonly NPCSystem _npc = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; public override void Initialize() { @@ -70,8 +72,7 @@ public override void Update(float frameTime) Dirty(comp); var location = xform.LocalPosition; - _chat.DispatchGlobalAnnouncement(Loc.GetString("carp-rift-warning", ("location", location)), playSound: false, colorOverride: Color.Red); - _audio.PlayGlobal("/Audio/Misc/notice1.ogg", Filter.Broadcast(), true); + _announcer.SendAnnouncement("carprift", Filter.Broadcast(), Loc.GetString("carp-rift-warning", ("location", location)), colorOverride: Color.Red); // Parkstation-RandomAnnouncers _navMap.SetBeaconEnabled(uid, true); } diff --git a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs index 5bce7f20e4..8b4dd4ac4c 100644 --- a/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/NukeopsRuleSystem.cs @@ -23,6 +23,7 @@ using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Events; using Content.Server.Shuttles.Systems; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Spawners.Components; using Content.Server.Station.Components; using Content.Server.Station.Systems; @@ -86,6 +87,7 @@ public sealed class NukeopsRuleSystem : GameRuleSystem [Dependency] private readonly IAdminManager _adminManager = default!; [Dependency] private readonly IConfigurationManager _cfg = default!; [Dependency] private readonly WarDeclaratorSystem _warDeclarator = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; [ValidatePrototypeId] @@ -211,7 +213,7 @@ public void DeclareWar(EntityUid opsUid, string msg, string title, SoundSpecifie var nukieRule = comps.Value.Item1; nukieRule.WarDeclaredTime = _gameTiming.CurTime; - _chat.DispatchGlobalAnnouncement(msg, title, announcementSound: announcementSound, colorOverride: colorOverride); + _announcer.SendAnnouncement("war", Filter.Broadcast(), msg, title, colorOverride); // Parkstation-RandomAnnouncers DistributeExtraTC(nukieRule); _warDeclarator.RefreshAllUI(comps.Value.Item1, comps.Value.Item2); } diff --git a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs index 886ff965c7..b34c2f137b 100644 --- a/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/ZombieRuleSystem.cs @@ -8,6 +8,7 @@ using Content.Server.Preferences.Managers; using Content.Server.Roles; using Content.Server.RoundEnd; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Server.Zombies; @@ -49,6 +50,7 @@ public sealed class ZombieRuleSystem : GameRuleSystem [Dependency] private readonly SharedRoleSystem _roles = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; public override void Initialize() { @@ -128,7 +130,7 @@ private void CheckRoundEnd() comp.ShuttleCalled = true; foreach (var station in _station.GetStations()) { - _chat.DispatchStationAnnouncement(station, Loc.GetString("zombie-shuttle-call"), colorOverride: Color.Crimson); + _announcer.SendAnnouncement("shuttlecalled", _station.GetInOwningStation(station), Loc.GetString("zombie-shuttle-call"), colorOverride: Color.Crimson); // Parkstation-RandomAnnouncers } _roundEnd.RequestRoundEnd(null, false); } diff --git a/Content.Server/Nuke/NukeCodePaperSystem.cs b/Content.Server/Nuke/NukeCodePaperSystem.cs index 8df25feebf..6ab5ab761d 100644 --- a/Content.Server/Nuke/NukeCodePaperSystem.cs +++ b/Content.Server/Nuke/NukeCodePaperSystem.cs @@ -2,9 +2,11 @@ using Content.Server.Chat.Systems; using Content.Server.Fax; using Content.Server.Paper; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Station.Components; using Content.Server.Station.Systems; using Content.Shared.Paper; +using Robust.Shared.Player; using Robust.Shared.Random; using Robust.Shared.Utility; @@ -17,6 +19,7 @@ public sealed class NukeCodePaperSystem : EntitySystem [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly PaperSystem _paper = default!; [Dependency] private readonly FaxSystem _faxSystem = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; public override void Initialize() { @@ -79,7 +82,7 @@ public bool SendNukeCodes(EntityUid station) if (wasSent) { var msg = Loc.GetString("nuke-component-announcement-send-codes"); - _chatSystem.DispatchStationAnnouncement(station, msg, colorOverride: Color.Red); + _announcer.SendAnnouncement("nukecodes", Filter.Broadcast(), msg, colorOverride: Color.Red); // Parkstation-AnnouncerSystem } return wasSent; diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 77689c4e2b..d8b92b2cff 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -4,6 +4,7 @@ using Content.Server.Explosion.EntitySystems; using Content.Server.Pinpointer; using Content.Server.Popups; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Station.Systems; using Content.Shared.Audio; using Content.Shared.Containers.ItemSlots; @@ -40,6 +41,7 @@ public sealed class NukeSystem : EntitySystem [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; /// /// Used to calculate when the nuke song should start playing for maximum kino with the nuke sfx @@ -455,7 +457,7 @@ public void ArmBomb(EntityUid uid, NukeComponent? component = null) var announcement = Loc.GetString("nuke-component-announcement-armed", ("time", (int) component.RemainingTime), ("position", posText)); var sender = Loc.GetString("nuke-component-announcement-sender"); - _chatSystem.DispatchStationAnnouncement(stationUid ?? uid, announcement, sender, false, null, Color.Red); + _announcer.SendAnnouncementMessage("nukearm", announcement, sender, Color.Red, stationUid ?? uid); // Parkstation-RandomAnnouncers _sound.PlayGlobalOnStation(uid, _audio.GetSound(component.ArmSound)); @@ -493,7 +495,7 @@ public void DisarmBomb(EntityUid uid, NukeComponent? component = null) // warn a crew var announcement = Loc.GetString("nuke-component-announcement-unarmed"); var sender = Loc.GetString("nuke-component-announcement-sender"); - _chatSystem.DispatchStationAnnouncement(uid, announcement, sender, false); + _announcer.SendAnnouncementMessage("nukedisarm", announcement, sender, station: stationUid ?? uid); // Parkstation-RandomAnnouncers component.PlayedNukeSong = false; _sound.PlayGlobalOnStation(uid, _audio.GetSound(component.DisarmSound)); @@ -604,4 +606,3 @@ public sealed class NukeDisarmSuccessEvent : EntityEventArgs { } - diff --git a/Content.Server/PowerSink/PowerSinkSystem.cs b/Content.Server/PowerSink/PowerSinkSystem.cs index deb6693500..1a0ffccc23 100644 --- a/Content.Server/PowerSink/PowerSinkSystem.cs +++ b/Content.Server/PowerSink/PowerSinkSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Examine; using Robust.Shared.Utility; using Content.Server.Chat.Systems; +using Content.Server.SimpleStation14.Announcements.Systems; using Content.Server.Station.Systems; using Robust.Shared.Timing; using Robust.Shared.Audio; @@ -31,6 +32,7 @@ public sealed class PowerSinkSystem : EntitySystem [Dependency] private readonly ExplosionSystem _explosionSystem = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly StationSystem _station = default!; + [Dependency] private readonly AnnouncerSystem _announcer = default!; public override void Initialize() { @@ -133,12 +135,7 @@ private void NotifyStationOfImminentExplosion(EntityUid uid, PowerSinkComponent if (station == null) return; - _chat.DispatchStationAnnouncement( - station.Value, - Loc.GetString("powersink-immiment-explosion-announcement"), - playDefaultSound: true, - colorOverride: Color.Yellow - ); + _announcer.SendAnnouncement("powersinkexplosion", _station.GetInOwningStation(station.Value), Loc.GetString("powersink-immiment-explosion-announcement"), colorOverride: Color.Yellow, station: station.Value); // Parkstation-RandomAnnouncers } } } diff --git a/Content.Server/RoundEnd/RoundEndSystem.cs b/Content.Server/RoundEnd/RoundEndSystem.cs index 567eb48ed9..e005bd14ad 100644 --- a/Content.Server/RoundEnd/RoundEndSystem.cs +++ b/Content.Server/RoundEnd/RoundEndSystem.cs @@ -312,9 +312,12 @@ public void DoRoundEndBehavior(RoundEndBehavior behavior, // Check is shuttle called or not. We should only dispatch announcement if it's already called if (IsRoundEndRequested()) { - _chatSystem.DispatchGlobalAnnouncement(Loc.GetString(textAnnounce), + _announcer.SendAnnouncement("shuttlecalled", // Parkstation-RandomAnnouncers + Filter.Broadcast(), + Loc.GetString(textAnnounce), Loc.GetString(sender), - colorOverride: Color.Gold); + Color.Gold + ); } else { diff --git a/Content.Shared/SimpleStation14/Announcements/Systems/SharedAnnouncerSystem.cs b/Content.Shared/SimpleStation14/Announcements/Systems/SharedAnnouncerSystem.cs index a9da0c5d9a..6b617bec76 100644 --- a/Content.Shared/SimpleStation14/Announcements/Systems/SharedAnnouncerSystem.cs +++ b/Content.Shared/SimpleStation14/Announcements/Systems/SharedAnnouncerSystem.cs @@ -17,10 +17,10 @@ public sealed class SharedAnnouncerSystem : EntitySystem /// /// ID of the announcement from the announcer to get information for /// ID of the announcer to use instead of the current one - public string? GetAnnouncementPath(string announcementId, string announcerId) + public string GetAnnouncementPath(string announcementId, string announcerId) { if (!_proto.TryIndex(announcerId, out var announcer)) - return null; + return ""; // Get the announcement data from the announcer // Will be the fallback if the data for the announcementId is not found diff --git a/Resources/Prototypes/SimpleStation14/Announcers/template b/Resources/Prototypes/SimpleStation14/Announcers/template index 0c2c7b8410..b8c08d85e7 100644 --- a/Resources/Prototypes/SimpleStation14/Announcers/template +++ b/Resources/Prototypes/SimpleStation14/Announcers/template @@ -10,16 +10,15 @@ id: Announcer # Localized as "announcer--name" in chat basePath: /Audio/Codebase/Announcements/Announcer # Where to start looking for audio files baseAudioParams: # Default audio parameters for all announcements, all options explained later - volume: -7 # if this example is really loud, lower it to match the others' volume + volume: -7 # If this announcer is really loud, lower it to match the others' volume announcements: # List of all announcements this announcer has audio for, comment out unused ones - don't remove them # Template - id: template # Lowercase of the event ID, add "-complete" to the end for post-event announcements (endings) ignoreBasePath: false # If true, it will ignore the basePath and use the path as is path: template.ogg # Path to the file relative to basePath/, named with snake_case except for "-complete" collection: AnnouncerTemplateAnnouncements # Collection of audios to randomly use for this, will ignore path if set - Ignores basePath automatically! - message: announcer-announcement-template # Localization key for the announcement message to use instead of the default one + message: announcer-announcement-template # Localization key for the announcement message to use instead of the default one - NOTE this does not pass through previous loc args yet audioParams: # Overrides baseAudioParams entirely for this specific announcement, numbers are all floats - attenuation: LinearDistanceClamped # See AudioParams.cs for info - default is here volume: 3 # We don't want announcement volumes to vary too much - default is here pitch: 1 # Default is here playOffsetSeconds: 0 # How many seconds into the audio to start from - default is here @@ -36,6 +35,12 @@ path: spawn_announce.ogg - id: war # Nuclear Operative declaration of war path: war.ogg + - id: nukecodes # The station has been send nuclear activation codes + path: nuke_codes.ogg # Or command_report.ogg if you want + - id: nukearm # The nuke is active and ticking + path: nuke_arm.ogg + - id: nukedisarm # The nuke has been disarmed + path: nuke_disarm.ogg # Alert levels - id: alertgreen # Everything is fine @@ -62,6 +67,8 @@ ### Mid-Round Antagonists - id: deathmatch # Everyone is going to kill each other path: death_match.ogg + - id: powersinkexplosion # A power sink is about to overcharge and explode + path: powersink_explosion.ogg ### Events - id: anomalyspawn # An anomaly has spawned in a random place path: anomaly.ogg @@ -77,6 +84,8 @@ path: clerical_error.ogg - id: dragonspawn # A dragon has spawned in a random place path: dragon_spawn.ogg + - id: carprift # A dragon's carp rift is active + path: carp_rift.ogg - id: revenantspawn # A revenant has spawned (by a prober?) path: revenant_spawn.ogg - id: gasleak # A random gas is coming out of a random vent