Fix command hiding, add new chat properties to TorchChatMessage

This commit is contained in:
John Gross
2019-02-28 12:33:26 -08:00
parent c650e190fb
commit 5cf3ae1203
3 changed files with 20 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Engine.Multiplayer;
using Sandbox.Game.Gui;
using Sandbox.Game.Multiplayer;
using VRage.Game;
using VRage.Network;
@@ -28,6 +29,8 @@ namespace Torch.API.Managers
AuthorSteamId = null;
Author = author;
Message = message;
Channel = ChatChannel.Global;
Target = 0;
Font = font;
}
@@ -38,12 +41,14 @@ namespace Torch.API.Managers
/// <param name="authorSteamId">Author's steam ID</param>
/// <param name="message">Message</param>
/// <param name="font">Font</param>
public TorchChatMessage(string author, ulong authorSteamId, string message, string font = MyFontEnum.Blue)
public TorchChatMessage(string author, ulong authorSteamId, string message, ChatChannel channel, long target, string font = MyFontEnum.Blue)
{
Timestamp = DateTime.Now;
AuthorSteamId = authorSteamId;
Author = author;
Message = message;
Channel = channel;
Target = target;
Font = font;
}
@@ -59,6 +64,8 @@ namespace Torch.API.Managers
AuthorSteamId = authorSteamId;
Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player";
Message = message;
Channel = ChatChannel.Global;
Target = 0;
Font = font;
}
@@ -79,6 +86,14 @@ namespace Torch.API.Managers
/// </summary>
public readonly string Message;
/// <summary>
/// The chat channel the message is part of.
/// </summary>
public readonly ChatChannel Channel;
/// <summary>
/// The intended recipient of the message.
/// </summary>
public readonly long Target;
/// <summary>
/// The font, or null if default.
/// </summary>
public readonly string Font;

View File

@@ -108,7 +108,7 @@ namespace Torch.Managers.ChatManager
{
if (!sendToOthers)
return;
var torchMsg = new TorchChatMessage(MySession.Static.LocalHumanPlayer?.DisplayName ?? "Player", Sync.MyId, messageText);
var torchMsg = new TorchChatMessage(MySession.Static.LocalHumanPlayer?.DisplayName ?? "Player", Sync.MyId, messageText, ChatChannel.Global, 0);
bool consumed = RaiseMessageRecieved(torchMsg);
if (!consumed)
consumed = OfflineMessageProcessor(torchMsg);

View File

@@ -34,10 +34,11 @@ namespace Torch.Managers.ChatManager
context.GetPattern(target).Prefixes.Add(patchMethod);
}
private static void PrefixMessageProcessing(ref ChatMsg msg)
private static bool PrefixMessageProcessing(ref ChatMsg msg)
{
var consumed = false;
ChatManager?.RaiseMessageRecieved(msg, ref consumed);
return !consumed;
}
}
@@ -160,7 +161,7 @@ namespace Torch.Managers.ChatManager
internal void RaiseMessageRecieved(ChatMsg message, ref bool consumed)
{
var torchMsg = new TorchChatMessage(GetMemberName(message.Author), message.Author, message.Text);
var torchMsg = new TorchChatMessage(GetMemberName(message.Author), message.Author, message.Text, (ChatChannel)message.Channel, message.TargetId);
MessageProcessing?.Invoke(torchMsg, ref consumed);
if (!consumed)