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, /// /// 交互 (Interact) /// Interact, /// /// 喂食 (Feed) /// Feed, } /// /// 消息类型 MOD作者可以随便抽个不是MSGTYPE的数避免冲突,支持负数 /// [Line] public int 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 void SetContent(string content) { Content = content; } /// /// 获取消息内容(字符串) /// public string GetContent() { return Content; } /// /// 聊天结构 /// public struct Chat { /// /// 聊天内容 /// public string Content { get; set; } /// /// 消息类型 /// public enum Type { /// /// 私有 /// Private, /// /// 半公开 /// Internal, /// /// 公开 /// Public } /// /// 聊天类型 /// public Type ChatType { get; set; } /// /// 发送者名字 /// public string SendName { get; set; } } /// /// 交互结构 /// public struct Feed { /// /// 对方是否启用了数据计算 (并且未丢失小标) /// public bool EnableFunction { get; set; } /// /// 食物/物品 /// [Line()] public Food Item { get; set; } } /// /// 交互类型 /// public enum Interact { /// /// 摸身体 /// TouchHead, /// /// 摸头 /// TouchBody, /// /// 捏脸 /// TouchPinch, } }