]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
research console radio messages on unlock (#22166)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Wed, 6 Dec 2023 07:00:51 +0000 (02:00 -0500)
committerGitHub <noreply@github.com>
Wed, 6 Dec 2023 07:00:51 +0000 (18:00 +1100)
Content.Server/Radio/EntitySystems/RadioSystem.cs
Content.Server/Research/Components/ResearchConsoleComponent.cs
Content.Server/Research/Systems/ResearchSystem.Console.cs
Content.Server/Research/Systems/ResearchSystem.cs
Resources/Locale/en-US/research/components/research-console-component.ftl
Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml

index 92e8139c75c90116e1a720b92bc77a4a405882cb..8eccd4be6972d8bfdef299d4be1d67447519edc2 100644 (file)
@@ -10,6 +10,7 @@ using Content.Shared.Radio.Components;
 using Robust.Shared.Map;
 using Robust.Shared.Network;
 using Robust.Shared.Player;
+using Robust.Shared.Prototypes;
 using Robust.Shared.Random;
 using Robust.Shared.Replays;
 using Robust.Shared.Utility;
@@ -24,6 +25,7 @@ public sealed class RadioSystem : EntitySystem
     [Dependency] private readonly INetManager _netMan = default!;
     [Dependency] private readonly IReplayRecordingManager _replay = default!;
     [Dependency] private readonly IAdminLogManager _adminLogger = default!;
+    [Dependency] private readonly IPrototypeManager _prototype = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly ChatSystem _chat = default!;
 
@@ -52,12 +54,20 @@ public sealed class RadioSystem : EntitySystem
             _netMan.ServerSendMessage(args.ChatMsg, actor.PlayerSession.ConnectedClient);
     }
 
+    /// <summary>
+    /// Send radio message to all active radio listeners
+    /// </summary>
+    public void SendRadioMessage(EntityUid messageSource, string message, ProtoId<RadioChannelPrototype> channel, EntityUid radioSource, bool escapeMarkup = true)
+    {
+        SendRadioMessage(messageSource, message, _prototype.Index(channel), radioSource, escapeMarkup: escapeMarkup);
+    }
+
     /// <summary>
     /// Send radio message to all active radio listeners
     /// </summary>
     /// <param name="messageSource">Entity that spoke the message</param>
     /// <param name="radioSource">Entity that picked up the message and will send it, e.g. headset</param>
-    public void SendRadioMessage(EntityUid messageSource, string message, RadioChannelPrototype channel, EntityUid radioSource)
+    public void SendRadioMessage(EntityUid messageSource, string message, RadioChannelPrototype channel, EntityUid radioSource, bool escapeMarkup = true)
     {
         // TODO if radios ever garble / modify messages, feedback-prevention needs to be handled better than this.
         if (!_messages.Add(message))
@@ -70,6 +80,9 @@ public sealed class RadioSystem : EntitySystem
         name = FormattedMessage.EscapeText(name);
 
         var speech = _chat.GetSpeechVerb(messageSource, message);
+        var content = escapeMarkup
+            ? FormattedMessage.EscapeText(message)
+            : message;
 
         var wrappedMessage = Loc.GetString(speech.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap",
             ("color", channel.Color),
@@ -78,7 +91,7 @@ public sealed class RadioSystem : EntitySystem
             ("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
             ("channel", $"\\[{channel.LocalizedName}\\]"),
             ("name", name),
-            ("message", FormattedMessage.EscapeText(message)));
+            ("message", content));
 
         // most radios are relayed to chat, so lets parse the chat message beforehand
         var chat = new ChatMessage(
index 038357ef8ba3306c70b593d1cd673301b38b4426..bdd620e9b0cf77b6660b83863b4c878f18449355 100644 (file)
@@ -1,8 +1,15 @@
+using Content.Shared.Radio;
+using Robust.Shared.Prototypes;
+
 namespace Content.Server.Research.Components;
 
 [RegisterComponent]
 public sealed partial class ResearchConsoleComponent : Component
 {
-
+    /// <summary>
+    /// The radio channel that the unlock announcements are broadcast to.
+    /// </summary>
+    [DataField, ViewVariables(VVAccess.ReadWrite)]
+    public ProtoId<RadioChannelPrototype> AnnouncementChannel = "Science";
 }
 
index 6da547999dd739814fb58e1bdc857bbe4109cb5b..e802e2c7f9e9611bf41d1c033473c61fae9dc691 100644 (file)
@@ -3,6 +3,7 @@ using Content.Server.Research.Components;
 using Content.Server.UserInterface;
 using Content.Shared.Access.Components;
 using Content.Shared.Research.Components;
+using Content.Shared.Research.Prototypes;
 
 namespace Content.Server.Research.Systems;
 
@@ -25,6 +26,9 @@ public sealed partial class ResearchSystem
         if (!this.IsPowered(uid, EntityManager))
             return;
 
+        if (!PrototypeManager.TryIndex<TechnologyPrototype>(args.Id, out var technologyPrototype))
+            return;
+
         if (TryComp<AccessReaderComponent>(uid, out var access) && !_accessReader.IsAllowed(ent, uid, access))
         {
             _popup.PopupEntity(Loc.GetString("research-console-no-access-popup"), ent);
@@ -34,6 +38,10 @@ public sealed partial class ResearchSystem
         if (!UnlockTechnology(uid, args.Id, ent))
             return;
 
+        var message = Loc.GetString("research-console-unlock-technology-radio-broadcast",
+            ("technology", Loc.GetString(technologyPrototype.Name)),
+            ("amount", technologyPrototype.Cost));
+        _radio.SendRadioMessage(uid, message, component.AnnouncementChannel, uid, escapeMarkup: false);
         SyncClientWithServer(uid);
         UpdateConsoleInterface(uid, component);
     }
index e89b435800f083a742a18f27567f838f86a56016..f8c4d6902a1aecba7b7215b5bb17a2db41033b2a 100644 (file)
@@ -1,6 +1,7 @@
 using System.Diagnostics.CodeAnalysis;
 using System.Linq;
 using Content.Server.Administration.Logs;
+using Content.Server.Radio.EntitySystems;
 using Content.Shared.Access.Systems;
 using Content.Shared.Popups;
 using Content.Shared.Research.Components;
@@ -19,6 +20,7 @@ namespace Content.Server.Research.Systems
         [Dependency] private readonly AccessReaderSystem _accessReader = default!;
         [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
         [Dependency] private readonly SharedPopupSystem _popup = default!;
+        [Dependency] private readonly RadioSystem _radio = default!;
 
         public override void Initialize()
         {
index 196983efcd43ec7d6a7d3dd5fc87b8bdb6bc3c90..33070480e54c534c19e0d9afba8a7f72c49a7115 100644 (file)
@@ -18,3 +18,4 @@ research-console-prereqs-list-start = Requires:
 research-console-prereqs-list-entry = - [color=orchid]{$text}[/color]
 
 research-console-no-access-popup = No access!
+research-console-unlock-technology-radio-broadcast = Unlocked [bold]{$technology}[/bold] for [bold]{$amount}[/bold] research.
index d4cc456eda89fb8457db63eed2b1eca9d4f51f02..24e828bf847337dea9e9777335c115bcccb43c5c 100644 (file)
       state: rd_key
   - type: ResearchClient
   - type: ResearchConsole
+  - type: ActiveRadio
+    channels:
+    - Science
   - type: TechnologyDatabase
   - type: ActivatableUI
     key: enum.ResearchConsoleUiKey.Key