research console radio messages on unlock (#22166)
This commit is contained in:
@@ -10,6 +10,7 @@ using Content.Shared.Radio.Components;
|
|||||||
using Robust.Shared.Map;
|
using Robust.Shared.Map;
|
||||||
using Robust.Shared.Network;
|
using Robust.Shared.Network;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using Robust.Shared.Replays;
|
using Robust.Shared.Replays;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
@@ -24,6 +25,7 @@ public sealed class RadioSystem : EntitySystem
|
|||||||
[Dependency] private readonly INetManager _netMan = default!;
|
[Dependency] private readonly INetManager _netMan = default!;
|
||||||
[Dependency] private readonly IReplayRecordingManager _replay = default!;
|
[Dependency] private readonly IReplayRecordingManager _replay = default!;
|
||||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||||
|
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly ChatSystem _chat = default!;
|
[Dependency] private readonly ChatSystem _chat = default!;
|
||||||
|
|
||||||
@@ -52,12 +54,20 @@ public sealed class RadioSystem : EntitySystem
|
|||||||
_netMan.ServerSendMessage(args.ChatMsg, actor.PlayerSession.ConnectedClient);
|
_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>
|
/// <summary>
|
||||||
/// Send radio message to all active radio listeners
|
/// Send radio message to all active radio listeners
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="messageSource">Entity that spoke the message</param>
|
/// <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>
|
/// <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.
|
// TODO if radios ever garble / modify messages, feedback-prevention needs to be handled better than this.
|
||||||
if (!_messages.Add(message))
|
if (!_messages.Add(message))
|
||||||
@@ -70,6 +80,9 @@ public sealed class RadioSystem : EntitySystem
|
|||||||
name = FormattedMessage.EscapeText(name);
|
name = FormattedMessage.EscapeText(name);
|
||||||
|
|
||||||
var speech = _chat.GetSpeechVerb(messageSource, message);
|
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",
|
var wrappedMessage = Loc.GetString(speech.Bold ? "chat-radio-message-wrap-bold" : "chat-radio-message-wrap",
|
||||||
("color", channel.Color),
|
("color", channel.Color),
|
||||||
@@ -78,7 +91,7 @@ public sealed class RadioSystem : EntitySystem
|
|||||||
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
|
("verb", Loc.GetString(_random.Pick(speech.SpeechVerbStrings))),
|
||||||
("channel", $"\\[{channel.LocalizedName}\\]"),
|
("channel", $"\\[{channel.LocalizedName}\\]"),
|
||||||
("name", name),
|
("name", name),
|
||||||
("message", FormattedMessage.EscapeText(message)));
|
("message", content));
|
||||||
|
|
||||||
// most radios are relayed to chat, so lets parse the chat message beforehand
|
// most radios are relayed to chat, so lets parse the chat message beforehand
|
||||||
var chat = new ChatMessage(
|
var chat = new ChatMessage(
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
|
using Content.Shared.Radio;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.Research.Components;
|
namespace Content.Server.Research.Components;
|
||||||
|
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
public sealed partial class ResearchConsoleComponent : Component
|
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";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Content.Server.Research.Components;
|
|||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
using Content.Shared.Access.Components;
|
using Content.Shared.Access.Components;
|
||||||
using Content.Shared.Research.Components;
|
using Content.Shared.Research.Components;
|
||||||
|
using Content.Shared.Research.Prototypes;
|
||||||
|
|
||||||
namespace Content.Server.Research.Systems;
|
namespace Content.Server.Research.Systems;
|
||||||
|
|
||||||
@@ -25,6 +26,9 @@ public sealed partial class ResearchSystem
|
|||||||
if (!this.IsPowered(uid, EntityManager))
|
if (!this.IsPowered(uid, EntityManager))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!PrototypeManager.TryIndex<TechnologyPrototype>(args.Id, out var technologyPrototype))
|
||||||
|
return;
|
||||||
|
|
||||||
if (TryComp<AccessReaderComponent>(uid, out var access) && !_accessReader.IsAllowed(ent, uid, access))
|
if (TryComp<AccessReaderComponent>(uid, out var access) && !_accessReader.IsAllowed(ent, uid, access))
|
||||||
{
|
{
|
||||||
_popup.PopupEntity(Loc.GetString("research-console-no-access-popup"), ent);
|
_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))
|
if (!UnlockTechnology(uid, args.Id, ent))
|
||||||
return;
|
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);
|
SyncClientWithServer(uid);
|
||||||
UpdateConsoleInterface(uid, component);
|
UpdateConsoleInterface(uid, component);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.Administration.Logs;
|
using Content.Server.Administration.Logs;
|
||||||
|
using Content.Server.Radio.EntitySystems;
|
||||||
using Content.Shared.Access.Systems;
|
using Content.Shared.Access.Systems;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Research.Components;
|
using Content.Shared.Research.Components;
|
||||||
@@ -19,6 +20,7 @@ namespace Content.Server.Research.Systems
|
|||||||
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
[Dependency] private readonly AccessReaderSystem _accessReader = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly RadioSystem _radio = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -18,3 +18,4 @@ research-console-prereqs-list-start = Requires:
|
|||||||
research-console-prereqs-list-entry = - [color=orchid]{$text}[/color]
|
research-console-prereqs-list-entry = - [color=orchid]{$text}[/color]
|
||||||
|
|
||||||
research-console-no-access-popup = No access!
|
research-console-no-access-popup = No access!
|
||||||
|
research-console-unlock-technology-radio-broadcast = Unlocked [bold]{$technology}[/bold] for [bold]{$amount}[/bold] research.
|
||||||
|
|||||||
@@ -374,6 +374,9 @@
|
|||||||
state: rd_key
|
state: rd_key
|
||||||
- type: ResearchClient
|
- type: ResearchClient
|
||||||
- type: ResearchConsole
|
- type: ResearchConsole
|
||||||
|
- type: ActiveRadio
|
||||||
|
channels:
|
||||||
|
- Science
|
||||||
- type: TechnologyDatabase
|
- type: TechnologyDatabase
|
||||||
- type: ActivatableUI
|
- type: ActivatableUI
|
||||||
key: enum.ResearchConsoleUiKey.Key
|
key: enum.ResearchConsoleUiKey.Key
|
||||||
|
|||||||
Reference in New Issue
Block a user