VPet/VPet-Simulator.Windows.Interface/MPMessage.cs

63 lines
1.5 KiB
C#
Raw Normal View History

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;
namespace VPet_Simulator.Windows.Interface;
/// <summary>
/// 多人模式传输的消息
/// </summary>
public struct MPMessage
{
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>
/// 聊天消息 (string)
/// </summary>
Message,
/// <summary>
/// 显示动画 (graphinfo)
/// </summary>
DispayGraph,
/// <summary>
/// 摸身体
/// </summary>
TouchHead,
/// <summary>
/// 摸头
/// </summary>
TouchBody,
/// <summary>
/// 喂食
/// </summary>
Feed,
}
/// <summary>
/// 消息类型
/// </summary>
2024-03-18 06:59:05 +00:00
[Line] public MSGType Type { get; set; }
2024-03-16 16:41:20 +00:00
/// <summary>
/// 消息内容
/// </summary>
2024-03-18 06:59:05 +00:00
[Line] public 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
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-16 16:41:20 +00:00
}