2024-03-16 16:41:20 +00:00
|
|
|
|
using LinePutScript;
|
|
|
|
|
using LinePutScript.Converter;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-03-18 13:34:41 +00:00
|
|
|
|
using System.Windows.Interop;
|
|
|
|
|
using VPet_Simulator.Core;
|
2024-03-16 16:41:20 +00:00
|
|
|
|
|
|
|
|
|
namespace VPet_Simulator.Windows.Interface;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 多人模式传输的消息
|
|
|
|
|
/// </summary>
|
|
|
|
|
public struct MPMessage
|
2024-03-17 18:22:47 +00:00
|
|
|
|
{
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 消息类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum MSGType
|
|
|
|
|
{
|
2024-03-18 06:59:05 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 一般是出错或者空消息
|
|
|
|
|
/// </summary>
|
|
|
|
|
Empty,
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// <summary>
|
2024-03-18 13:34:41 +00:00
|
|
|
|
/// 聊天消息 (chat)
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// </summary>
|
2024-03-18 13:34:41 +00:00
|
|
|
|
Chat,
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 显示动画 (graphinfo)
|
|
|
|
|
/// </summary>
|
|
|
|
|
DispayGraph,
|
|
|
|
|
/// <summary>
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// 交互 (Interact)
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// </summary>
|
2024-03-19 18:36:35 +00:00
|
|
|
|
Interact,
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// <summary>
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// 喂食 (Feed)
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
Feed,
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// 消息类型 MOD作者可以随便抽个不是MSGTYPE的数避免冲突,支持负数
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// </summary>
|
2024-03-19 15:14:19 +00:00
|
|
|
|
[Line] public int Type { get; set; }
|
2024-03-16 16:41:20 +00:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 消息内容
|
|
|
|
|
/// </summary>
|
2024-03-18 13:34:41 +00:00
|
|
|
|
[Line] private string Content { get; set; }
|
2024-03-16 16:41:20 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 被操作者 (显示动画用)
|
|
|
|
|
/// </summary>
|
2024-03-18 06:59:05 +00:00
|
|
|
|
[Line] public ulong To { get; set; }
|
2024-03-16 16:41:20 +00:00
|
|
|
|
|
2024-03-17 18:22:47 +00:00
|
|
|
|
public static byte[] ConverTo(MPMessage data) => Encoding.UTF8.GetBytes(LPSConvert.SerializeObject(data).ToString());
|
|
|
|
|
public static MPMessage ConverTo(byte[] data) => LPSConvert.DeserializeObject<MPMessage>(new LPS(Encoding.UTF8.GetString(data)));
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置消息内容(类)
|
|
|
|
|
/// </summary>
|
2024-03-18 13:34:41 +00:00
|
|
|
|
public void SetContent(object content)
|
|
|
|
|
{
|
|
|
|
|
Content = LPSConvert.GetObjectString(content, convertNoneLineAttribute: true);
|
|
|
|
|
}
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取消息内容(类)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T">类类型</typeparam>
|
2024-03-18 13:34:41 +00:00
|
|
|
|
public T GetContent<T>()
|
|
|
|
|
{
|
|
|
|
|
return (T)LPSConvert.GetStringObject(Content, typeof(T), convertNoneLineAttribute: true);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// 设置消息内容(字符串)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void SetContent(string content)
|
|
|
|
|
{
|
|
|
|
|
Content = content;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取消息内容(字符串)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string GetContent()
|
|
|
|
|
{
|
|
|
|
|
return Content;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
2024-03-18 13:34:41 +00:00
|
|
|
|
/// 聊天结构
|
|
|
|
|
/// </summary>
|
|
|
|
|
public struct Chat
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 聊天内容
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Content { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 消息类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum Type
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 私有
|
|
|
|
|
/// </summary>
|
|
|
|
|
Private,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 半公开
|
|
|
|
|
/// </summary>
|
|
|
|
|
Internal,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 公开
|
|
|
|
|
/// </summary>
|
|
|
|
|
Public
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 聊天类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public Type ChatType { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 发送者名字
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string SendName { get; set; }
|
|
|
|
|
}
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 交互结构
|
|
|
|
|
/// </summary>
|
|
|
|
|
public struct Feed
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 对方是否启用了数据计算 (并且未丢失小标)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool EnableFunction { get; set; }
|
|
|
|
|
/// <summary>
|
2024-03-20 18:59:11 +00:00
|
|
|
|
/// 食物/物品
|
2024-03-19 18:36:35 +00:00
|
|
|
|
/// </summary>
|
2024-03-20 18:59:11 +00:00
|
|
|
|
[Line()]
|
|
|
|
|
public Food Item { get; set; }
|
2024-03-19 18:36:35 +00:00
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 交互类型
|
|
|
|
|
/// </summary>
|
|
|
|
|
public enum Interact
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 摸身体
|
|
|
|
|
/// </summary>
|
|
|
|
|
TouchHead,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 摸头
|
|
|
|
|
/// </summary>
|
|
|
|
|
TouchBody,
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 捏脸
|
|
|
|
|
/// </summary>
|
|
|
|
|
TouchPinch,
|
|
|
|
|
}
|
2024-03-16 16:41:20 +00:00
|
|
|
|
}
|