using LinePutScript;
using LinePutScript.Converter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Interop;
using VPet_Simulator.Core;
namespace VPet_Simulator.Windows.Interface;
///
/// 多人模式传输的消息
///
public struct MPMessage
{
///
/// 消息类型
///
public enum MSGType
{
///
/// 一般是出错或者空消息
///
Empty,
///
/// 聊天消息 (chat)
///
Chat,
///
/// 显示动画 (graphinfo)
///
DispayGraph,
///
/// 摸身体
///
TouchHead,
///
/// 摸头
///
TouchBody,
///
/// 喂食
///
Feed,
}
///
/// 消息类型
///
[Line] public MSGType Type { get; set; }
///
/// 消息内容
///
[Line] private string Content { get; set; }
///
/// 被操作者 (显示动画用)
///
[Line] public ulong To { get; set; }
public static byte[] ConverTo(MPMessage data) => Encoding.UTF8.GetBytes(LPSConvert.SerializeObject(data).ToString());
public static MPMessage ConverTo(byte[] data) => LPSConvert.DeserializeObject(new LPS(Encoding.UTF8.GetString(data)));
public void SetContent(object content)
{
Content = LPSConvert.GetObjectString(content, convertNoneLineAttribute: true);
}
public T GetContent()
{
return (T)LPSConvert.GetStringObject(Content, typeof(T), convertNoneLineAttribute: true);
}
///
/// 聊天结构
///
public struct Chat
{
///
/// 聊天内容
///
public string Content { get; set; }
///
/// 消息类型
///
public enum Type
{
///
/// 私有
///
Private,
///
/// 半公开
///
Internal,
///
/// 公开
///
Public
}
///
/// 聊天类型
///
public Type ChatType { get; set; }
///
/// 发送者名字
///
public string SendName { get; set; }
}
}