0
0
Fork 0
mirror of https://github.com/Sanae6/SmoOnlineServer.git synced 2024-11-15 08:05:06 +00:00
SmoOnlineServer/Shared/Packet/Packets/CostumePacket.cs

23 lines
863 B
C#
Raw Normal View History

2022-02-04 09:45:38 +00:00
using System.Runtime.InteropServices;
using System.Text;
2022-02-04 09:45:38 +00:00
2022-02-10 01:44:50 +00:00
namespace Shared.Packet.Packets;
2022-02-04 09:45:38 +00:00
[Packet(PacketType.Costume)]
public struct CostumePacket : IPacket {
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
2022-02-04 09:45:38 +00:00
public string BodyName;
2022-02-10 01:44:50 +00:00
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = Constants.CostumeNameSize)]
2022-02-04 09:45:38 +00:00
public string CapName;
2022-02-10 01:44:50 +00:00
2022-02-04 09:45:38 +00:00
public void Serialize(Span<byte> data) {
Encoding.UTF8.GetBytes(BodyName).CopyTo(data[..Constants.CostumeNameSize]);
Encoding.UTF8.GetBytes(CapName).CopyTo(data[Constants.CostumeNameSize..]);
2022-02-04 09:45:38 +00:00
}
public void Deserialize(Span<byte> data) {
BodyName = Encoding.UTF8.GetString(data[..Constants.CostumeNameSize]).TrimNullTerm();
CapName = Encoding.UTF8.GetString(data[Constants.CostumeNameSize..]).TrimNullTerm();
2022-02-04 09:45:38 +00:00
}
2021-11-29 04:04:34 +00:00
}