Added Whisper system for talking with players 2 tiles away. (#5994)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
Michael Phillips
2022-01-11 06:48:18 -08:00
committed by GitHub
parent b3706b9467
commit 86812c1ad7
24 changed files with 406 additions and 225 deletions

View File

@@ -1,12 +1,8 @@
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Content.Server.Ghost.Components;
using Content.Server.Players;
using Content.Shared.Administration;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Server.Chat.Commands
@@ -22,7 +18,7 @@ namespace Content.Server.Chat.Commands
{
if (shell.Player is not IPlayerSession player)
{
shell.WriteLine("This command cannot be run from the server.");
shell.WriteError("This command cannot be run from the server.");
return;
}
@@ -31,7 +27,7 @@ namespace Content.Server.Chat.Commands
if (player.AttachedEntity is not {} playerEntity)
{
shell.WriteLine("You don't have an entity!");
shell.WriteError("You don't have an entity!");
return;
}
@@ -42,34 +38,7 @@ namespace Content.Server.Chat.Commands
if (string.IsNullOrEmpty(message))
return;
var chat = IoCManager.Resolve<IChatManager>();
var chatSanitizer = IoCManager.Resolve<IChatSanitizationManager>();
if (IoCManager.Resolve<IEntityManager>().HasComponent<GhostComponent>(playerEntity))
chat.SendDeadChat(player, message);
else
{
var mindComponent = player.ContentData()?.Mind;
if (mindComponent == null)
{
shell.WriteError("You don't have a mind!");
return;
}
if (mindComponent.OwnedEntity is not {Valid: true} owned)
{
shell.WriteError("You don't have an entity!");
return;
}
var emote = chatSanitizer.TrySanitizeOutSmilies(message, owned, out var sanitized, out var emoteStr);
if (sanitized.Length != 0)
chat.EntitySay(owned, sanitized);
if (emote)
chat.EntityMe(owned, emoteStr!);
}
IoCManager.Resolve<IChatManager>().TrySpeak(playerEntity, message, false, shell, player);
}
}
}