using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sandbox.Engine.Multiplayer;
using Sandbox.Game.Multiplayer;
using VRage.Network;
namespace Torch.API.Managers
{
///
/// Represents a scripted or user chat message.
///
public struct TorchChatMessage
{
///
/// Creates a new torch chat message with the given author and message.
///
/// Author's name
/// Message
public TorchChatMessage(string author, string message)
{
Timestamp = DateTime.Now;
AuthorSteamId = null;
Author = author;
Message = message;
Font = "Blue";
}
///
/// Creates a new torch chat message with the given author and message.
///
/// Author's steam ID
/// Message
public TorchChatMessage(ulong authorSteamId, string message)
{
Timestamp = DateTime.Now;
AuthorSteamId = authorSteamId;
Author = MyMultiplayer.Static?.GetMemberName(authorSteamId) ?? "Player";
Message = message;
Font = "Blue";
}
///
/// This message's timestamp.
///
public DateTime Timestamp;
///
/// The author's steam ID, if available. Else, null.
///
public ulong? AuthorSteamId;
///
/// The author's name, if available. Else, null.
///
public string Author;
///
/// The message contents.
///
public string Message;
///
/// The font, or null if default.
///
public string Font;
}
///
/// Callback used to indicate that a messaage has been recieved.
///
///
/// If true, this event has been consumed and should be ignored
public delegate void MessageRecievedDel(TorchChatMessage msg, ref bool consumed);
///
/// Callback used to indicate the user is attempting to send a message locally.
///
/// Message the user is attempting to send
/// If true, this event has been consumed and should be ignored
public delegate void MessageSendingDel(string msg, ref bool consumed);
public interface IChatManagerClient : IManager
{
///
/// Event that is raised when a message addressed to us is recieved.
///
event MessageRecievedDel MessageRecieved;
///
/// Event that is raised when we are attempting to send a message.
///
event MessageSendingDel MessageSending;
///
/// Triggers the event,
/// typically raised by the user entering text into the chat window.
///
/// The message to send
void SendMessageAsSelf(string message);
///
/// Displays a message on the UI given an author name and a message.
///
/// Author name
/// Message content
/// font to use
void DisplayMessageOnSelf(string author, string message, string font = "Blue" );
}
}