Adds /me command. (#414)
* Adds /me command. * Update Content.Server/Chat/ChatManager.cs Co-Authored-By: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
committed by
Pieter-Jan Briers
parent
12cf5559c2
commit
7d307832a0
@@ -28,6 +28,28 @@ namespace Content.Server.Chat
|
||||
}
|
||||
}
|
||||
|
||||
internal class MeCommand : IClientCommand
|
||||
{
|
||||
public string Command => "me";
|
||||
public string Description => "Perform an action.";
|
||||
public string Help => "me <text>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
{
|
||||
if (player.Status != SessionStatus.InGame || !player.AttachedEntityUid.HasValue)
|
||||
return;
|
||||
|
||||
if (args.Length < 1)
|
||||
return;
|
||||
|
||||
var chat = IoCManager.Resolve<IChatManager>();
|
||||
|
||||
var action = string.Join(" ", args);
|
||||
|
||||
chat.EntityMe(player.AttachedEntity, action);
|
||||
}
|
||||
}
|
||||
|
||||
internal class OOCCommand : IClientCommand
|
||||
{
|
||||
public string Command => "ooc";
|
||||
|
||||
@@ -65,6 +65,24 @@ namespace Content.Server.Chat
|
||||
_netManager.ServerSendToMany(msg, clients.ToList());
|
||||
}
|
||||
|
||||
public void EntityMe(IEntity source, string action)
|
||||
{
|
||||
if (!ActionBlockerSystem.CanEmote(source))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var pos = source.Transform.GridPosition;
|
||||
var clients = _playerManager.GetPlayersInRange(pos, VoiceRange).Select(p => p.ConnectedClient);
|
||||
|
||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||
msg.Channel = ChatChannel.Emotes;
|
||||
msg.Message = action;
|
||||
msg.MessageWrap = $"{source.Name} {{0}}";
|
||||
msg.SenderEntity = source.Uid;
|
||||
_netManager.ServerSendToMany(msg, clients.ToList());
|
||||
}
|
||||
|
||||
public void SendOOC(IPlayerSession player, string message)
|
||||
{
|
||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||
|
||||
Reference in New Issue
Block a user