From 123db00bb4eb3f2b45c91ea88c06d68522bcd2dd Mon Sep 17 00:00:00 2001 From: ReeZer2 Date: Tue, 13 Aug 2024 19:09:00 +0300 Subject: [PATCH] ADD traitor codewords highlight --- .../Systems/Chat/Widgets/ChatBox.xaml.cs | 16 ++++++++++++++++ .../GameTicking/Rules/TraitorRuleSystem.cs | 8 ++++++++ .../ShowCodewords/ShowCodewordsComponent.cs | 11 +++++++++++ 3 files changed, 35 insertions(+) create mode 100644 Content.Shared/SS220/ShowCodewords/ShowCodewordsComponent.cs diff --git a/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs b/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs index 9853ddcf411d08..a8a0ee2d284bb3 100644 --- a/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs +++ b/Content.Client/UserInterface/Systems/Chat/Widgets/ChatBox.xaml.cs @@ -1,9 +1,11 @@ using Content.Client.UserInterface.Systems.Chat.Controls; using Content.Shared.Chat; using Content.Shared.Input; +using Content.Shared.SS220.ShowCodewords; using Robust.Client.Audio; using Robust.Client.AutoGenerated; using Robust.Client.GameObjects; +using Robust.Client.Player; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; @@ -65,6 +67,20 @@ private void OnMessageAdded(ChatMessage msg) var color = msg.MessageColorOverride ?? msg.Channel.TextColor(); + //ss220 codewords highlight add start + var playerManager = IoCManager.Resolve(); + var entManager = IoCManager.Resolve(); + + if (playerManager.LocalEntity != null && + entManager.TryGetComponent(playerManager.LocalEntity, out var showCodewordsComponent)) + { + foreach (var codeword in showCodewordsComponent.CodeWords) + { + msg.WrappedMessage = msg.WrappedMessage.Replace(codeword, $"[color=pink]{codeword}[/color]"); + } + } + //ss220 codewords highlight add end + AddLine(msg.WrappedMessage, color); } diff --git a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs index a75d43169043f3..e033d37c645aaf 100644 --- a/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs +++ b/Content.Server/GameTicking/Rules/TraitorRuleSystem.cs @@ -18,6 +18,7 @@ using System.Text; using Content.Shared.GameTicking.Components; using Content.Server.SS220.MindSlave; +using Content.Shared.SS220.ShowCodewords; namespace Content.Server.GameTicking.Rules; @@ -106,6 +107,13 @@ public bool MakeTraitor(EntityUid traitor, TraitorRuleComponent component, bool component.TraitorMinds.Add(mindId); + //ss220 codewords highlight add start + + var showCodewordsComp = EnsureComp(traitor); + showCodewordsComp.CodeWords = component.Codewords; + + //ss220 codewords highlight add end + // Assign briefing _roleSystem.MindAddRole(mindId, new RoleBriefingComponent { diff --git a/Content.Shared/SS220/ShowCodewords/ShowCodewordsComponent.cs b/Content.Shared/SS220/ShowCodewords/ShowCodewordsComponent.cs new file mode 100644 index 00000000000000..2f82b2c3d61efd --- /dev/null +++ b/Content.Shared/SS220/ShowCodewords/ShowCodewordsComponent.cs @@ -0,0 +1,11 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.SS220.ShowCodewords; + +[RegisterComponent, NetworkedComponent] +[AutoGenerateComponentState] +public sealed partial class ShowCodewordsComponent : Component +{ + [DataField("codewords"), ViewVariables(VVAccess.ReadWrite), AutoNetworkedField] + public string[] CodeWords; +}