Glorfcode (force say on damage/stun/crit) (#20562)
This commit is contained in:
@@ -16,6 +16,7 @@ using Content.Client.UserInterface.Systems.Gameplay;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.Damage.ForceSay;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Radio;
|
||||
@@ -30,6 +31,7 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Random;
|
||||
using Robust.Shared.Replays;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -164,6 +166,7 @@ public sealed class ChatUIController : UIController
|
||||
_player.LocalPlayerChanged += OnLocalPlayerChanged;
|
||||
_state.OnStateChanged += StateChanged;
|
||||
_net.RegisterNetMessage<MsgChatMessage>(OnChatMessage);
|
||||
SubscribeNetworkEvent<DamageForceSayEvent>(OnDamageForceSay);
|
||||
|
||||
_speechBubbleRoot = new LayoutContainer();
|
||||
|
||||
@@ -774,6 +777,37 @@ public sealed class ChatUIController : UIController
|
||||
_manager.SendMessage(text, prefixChannel == 0 ? channel : prefixChannel);
|
||||
}
|
||||
|
||||
private void OnDamageForceSay(DamageForceSayEvent ev, EntitySessionEventArgs _)
|
||||
{
|
||||
if (UIManager.ActiveScreen?.GetWidget<ChatBox>() is not { } chatBox)
|
||||
return;
|
||||
|
||||
// Don't send on OOC/LOOC obviously!
|
||||
if (chatBox.SelectedChannel is not
|
||||
(ChatSelectChannel.Local or
|
||||
ChatSelectChannel.Radio or
|
||||
ChatSelectChannel.Whisper))
|
||||
return;
|
||||
|
||||
if (_player.LocalPlayer?.ControlledEntity is not { } ent
|
||||
|| !EntityManager.TryGetComponent<DamageForceSayComponent>(ent, out var forceSay))
|
||||
return;
|
||||
|
||||
var msg = chatBox.ChatInput.Input.Text.TrimEnd();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(msg))
|
||||
return;
|
||||
|
||||
var modifiedText = ev.Suffix != null
|
||||
? Loc.GetString(forceSay.ForceSayMessageWrap,
|
||||
("message", msg), ("suffix", ev.Suffix))
|
||||
: Loc.GetString(forceSay.ForceSayMessageWrapNoSuffix,
|
||||
("message", msg));
|
||||
|
||||
chatBox.ChatInput.Input.SetText(modifiedText);
|
||||
chatBox.ChatInput.Input.ForceSubmitText();
|
||||
}
|
||||
|
||||
private void OnChatMessage(MsgChatMessage message)
|
||||
{
|
||||
var msg = message.Message;
|
||||
|
||||
Reference in New Issue
Block a user