Skip to content

Commit

Permalink
Subtle Command
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxxoTrystan committed Jul 7, 2024
1 parent 7db0342 commit 90dfe8b
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Content.Server/Chat/Commands/SubtleCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Content.Server.Chat.Systems;
using Content.Shared.Administration;
using Robust.Shared.Console;
using Robust.Shared.Enums;

namespace Content.Server.Chat.Commands
{
[AnyCommand]
internal sealed class SubtleCommand : IConsoleCommand
{
public string Command => "subtle";
public string Description => "Perform an subtle action.";
public string Help => "subtle <text>";

public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (shell.Player is not { } player)
{
shell.WriteError("This command cannot be run from the server.");
return;
}

if (player.Status != SessionStatus.InGame)
return;

if (player.AttachedEntity is not {} playerEntity)
{
shell.WriteError("You don't have an entity!");
return;
}

if (args.Length < 1)
return;

var message = string.Join(" ", args).Trim();
if (string.IsNullOrEmpty(message))
return;

IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>()
.TrySendInGameICMessage(playerEntity, message, InGameICChatType.Subtle, ChatTransmitRange.NoGhosts, false, shell, player);
}
}
}
45 changes: 45 additions & 0 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,9 @@ public void TrySendInGameICMessage(
case InGameICChatType.Emote:
SendEntityEmote(source, message, range, nameOverride, hideLog: hideLog, ignoreActionBlocker: ignoreActionBlocker);
break;
case InGameICChatType.Subtle:
SendEntitySubtle(source, message, range, nameOverride, hideLog: hideLog, ignoreActionBlocker: ignoreActionBlocker);
break;
//Nyano - Summary: case adds the telepathic chat sending ability.
case InGameICChatType.Telepathic:
_nyanoChatSystem.SendTelepathicChat(source, message, range == ChatTransmitRange.HideChat);
Expand Down Expand Up @@ -596,6 +599,47 @@ private void SendEntityEmote(
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Emote from {ToPrettyString(source):user}: {action}");
}

private void SendEntitySubtle(
EntityUid source,
string action,
ChatTransmitRange range,
string? nameOverride,
bool hideLog = false,
bool ignoreActionBlocker = false,
NetUserId? author = null
)
{
if (!_actionBlocker.CanEmote(source) && !ignoreActionBlocker)
return;

// get the entity's apparent name (if no override provided).
var ent = Identity.Entity(source, EntityManager);
string name = FormattedMessage.EscapeText(nameOverride ?? Name(ent));

// Emotes use Identity.Name, since it doesn't actually involve your voice at all.
var wrappedMessage = Loc.GetString("chat-manager-entity-subtle-wrap-message",
("entityName", name),
("entity", ent),
("message", FormattedMessage.RemoveMarkup(action)));

foreach (var (session, data) in GetRecipients(source, WhisperClearRange))
{
if (session.AttachedEntity is not { Valid: true } listener)
continue;

if (MessageRangeCheck(session, data, range) == MessageRangeCheckResult.Disallowed)
continue;

_chatManager.ChatMessageToOne(ChatChannel.Emotes, action, wrappedMessage, source, false, session.Channel);
}

if (!hideLog)
if (name != Name(source))
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Subtle from {ToPrettyString(source):user} as {name}: {action}");
else
_adminLogger.Add(LogType.Chat, LogImpact.Low, $"Subtle from {ToPrettyString(source):user}: {action}");
}

// ReSharper disable once InconsistentNaming
private void SendLOOC(EntityUid source, ICommonSession player, string message, bool hideChat)
{
Expand Down Expand Up @@ -1012,6 +1056,7 @@ public enum InGameICChatType : byte
Speak,
Emote,
Whisper,
Subtle, // FloofStation
Telepathic //Nyano - Summary: adds telepathic as a type of message users can receive.
}

Expand Down
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/chat/managers/chat-manager.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ chat-manager-entity-me-wrap-message = [italic]{ PROPER($entity) ->
[true] {$entityName} {$message}[/italic]
}
chat-manager-entity-subtle-wrap-message = [italic]{ PROPER($entity) ->
*[false] the {$entityName} subtly {$message}[/italic]
[true] {$entityName} subtly {$message}[/italic]
}
chat-manager-entity-looc-wrap-message = LOOC: {$entityName}: {$message}
chat-manager-send-ooc-wrap-message = OOC: {$playerName}: {$message}
chat-manager-send-ooc-patron-wrap-message = OOC: [color={$patronColor}]{$playerName}[/color]: {$message}
Expand Down

0 comments on commit 90dfe8b

Please sign in to comment.