quantum-space-buddies/QuantumUNET/Messages/QCRCMessage.cs

32 lines
770 B
C#
Raw Normal View History

using QuantumUNET.Transport;
namespace QuantumUNET.Messages
2020-12-02 18:40:38 +00:00
{
2020-12-23 12:58:45 +00:00
internal class QCRCMessage : QMessageBase
2020-12-02 18:40:38 +00:00
{
2020-12-23 12:58:45 +00:00
public QCRCMessageEntry[] scripts;
2020-12-03 11:56:32 +00:00
2020-12-23 12:58:45 +00:00
public override void Deserialize(QNetworkReader reader)
2020-12-02 18:40:38 +00:00
{
2020-12-03 11:56:32 +00:00
var num = (int)reader.ReadUInt16();
2020-12-23 12:58:45 +00:00
scripts = new QCRCMessageEntry[num];
2020-12-03 11:56:32 +00:00
for (var i = 0; i < scripts.Length; i++)
2020-12-02 18:40:38 +00:00
{
2020-12-23 12:58:45 +00:00
var crcmessageEntry = default(QCRCMessageEntry);
2020-12-02 18:40:38 +00:00
crcmessageEntry.name = reader.ReadString();
crcmessageEntry.channel = reader.ReadByte();
2020-12-03 11:56:32 +00:00
scripts[i] = crcmessageEntry;
2020-12-02 18:40:38 +00:00
}
}
2020-12-23 12:58:45 +00:00
public override void Serialize(QNetworkWriter writer)
2020-12-02 18:40:38 +00:00
{
2020-12-03 11:56:32 +00:00
writer.Write((ushort)scripts.Length);
for (var i = 0; i < scripts.Length; i++)
2020-12-02 18:40:38 +00:00
{
2020-12-03 11:56:32 +00:00
writer.Write(scripts[i].name);
writer.Write(scripts[i].channel);
2020-12-02 18:40:38 +00:00
}
}
}
2020-12-03 08:28:05 +00:00
}