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
|
internal class OOCCommand : IClientCommand
|
||||||
{
|
{
|
||||||
public string Command => "ooc";
|
public string Command => "ooc";
|
||||||
|
|||||||
@@ -65,6 +65,24 @@ namespace Content.Server.Chat
|
|||||||
_netManager.ServerSendToMany(msg, clients.ToList());
|
_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)
|
public void SendOOC(IPlayerSession player, string message)
|
||||||
{
|
{
|
||||||
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanEmote()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -97,6 +102,11 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanEmote()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -158,5 +168,10 @@ namespace Content.Server.GameObjects
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanEmote()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,6 +102,11 @@ namespace Content.Server.GameObjects
|
|||||||
return CurrentDamageState.CanSpeak();
|
return CurrentDamageState.CanSpeak();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IActionBlocker.CanEmote()
|
||||||
|
{
|
||||||
|
return CurrentDamageState.CanEmote();
|
||||||
|
}
|
||||||
|
|
||||||
List<DamageThreshold> IOnDamageBehavior.GetAllDamageThresholds()
|
List<DamageThreshold> IOnDamageBehavior.GetAllDamageThresholds()
|
||||||
{
|
{
|
||||||
var thresholdlist = DamageTemplate.DamageThresholds;
|
var thresholdlist = DamageTemplate.DamageThresholds;
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
bool CanThrow();
|
bool CanThrow();
|
||||||
|
|
||||||
bool CanSpeak();
|
bool CanSpeak();
|
||||||
|
|
||||||
|
bool CanEmote();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ActionBlockerSystem : EntitySystem
|
public class ActionBlockerSystem : EntitySystem
|
||||||
@@ -67,5 +69,17 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
}
|
}
|
||||||
return canspeak;
|
return canspeak;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static bool CanEmote(IEntity entity)
|
||||||
|
{
|
||||||
|
bool canemote = true;
|
||||||
|
|
||||||
|
foreach (var actionblockercomponents in entity.GetAllComponents<IActionBlocker>())
|
||||||
|
{
|
||||||
|
canemote &= actionblockercomponents.CanEmote();
|
||||||
|
}
|
||||||
|
|
||||||
|
return canemote;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace Content.Server.Interfaces.Chat
|
|||||||
void DispatchServerMessage(IPlayerSession player, string message);
|
void DispatchServerMessage(IPlayerSession player, string message);
|
||||||
|
|
||||||
void EntitySay(IEntity source, string message);
|
void EntitySay(IEntity source, string message);
|
||||||
|
void EntityMe(IEntity source, string action);
|
||||||
|
|
||||||
void SendOOC(IPlayerSession player, string message);
|
void SendOOC(IPlayerSession player, string message);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user