2017-05-09 03:25:04 +02:00
|
|
|
|
|
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
|
|
|
|
namespace Cyber.Networking.Messages {
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2017-05-11 21:00:52 +02:00
|
|
|
|
/// Packet containing integers, used in many packet types, such as <see cref="PktType.MassIdentity"/> and <see cref="PktType.StaticObjectIds"/>.
|
2017-05-09 03:25:04 +02:00
|
|
|
|
/// </summary>
|
2017-05-11 03:01:33 +02:00
|
|
|
|
public class IntListPkt : MessageBase {
|
2017-05-09 03:25:04 +02:00
|
|
|
|
|
2017-05-09 05:13:30 +02:00
|
|
|
|
/// <summary>
|
2017-05-11 03:01:33 +02:00
|
|
|
|
/// List of Integers.
|
2017-05-09 05:13:30 +02:00
|
|
|
|
/// </summary>
|
2017-05-16 23:41:03 +02:00
|
|
|
|
public int[] IntList;
|
2017-05-09 03:25:04 +02:00
|
|
|
|
|
2017-05-09 05:13:30 +02:00
|
|
|
|
/// <summary>
|
2017-05-11 03:01:33 +02:00
|
|
|
|
/// Create a packet containing integers.
|
2017-05-09 05:13:30 +02:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="idList"></param>
|
2017-05-11 03:01:33 +02:00
|
|
|
|
public IntListPkt(int[] idList) {
|
2017-05-16 23:41:03 +02:00
|
|
|
|
IntList = idList;
|
2017-05-09 03:25:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-09 05:13:30 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Parameter-less constructor using when deserializing the message.
|
|
|
|
|
/// </summary>
|
2017-05-11 03:01:33 +02:00
|
|
|
|
public IntListPkt() {
|
2017-05-09 03:25:04 +02:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-09 05:13:30 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to deserialize a message received via networking.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="reader"></param>
|
2017-05-09 03:25:04 +02:00
|
|
|
|
public override void Deserialize(NetworkReader reader) {
|
|
|
|
|
byte[][] ByteArray = new byte[4][];
|
|
|
|
|
ByteArray[0] = reader.ReadBytesAndSize();
|
|
|
|
|
ByteArray[1] = reader.ReadBytesAndSize();
|
|
|
|
|
ByteArray[2] = reader.ReadBytesAndSize();
|
|
|
|
|
ByteArray[3] = reader.ReadBytesAndSize();
|
2017-05-16 23:41:03 +02:00
|
|
|
|
IntList = NetworkHelper.DeserializeIntArray(ByteArray);
|
2017-05-09 03:25:04 +02:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-09 05:13:30 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Used to serialize the message before it is sent.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="writer"></param>
|
2017-05-09 03:25:04 +02:00
|
|
|
|
public override void Serialize(NetworkWriter writer) {
|
2017-05-16 23:41:03 +02:00
|
|
|
|
byte[][] ByteArray = NetworkHelper.SerializeIntArray(IntList);
|
2017-05-09 03:25:04 +02:00
|
|
|
|
writer.WriteBytesFull(ByteArray[0]);
|
|
|
|
|
writer.WriteBytesFull(ByteArray[1]);
|
|
|
|
|
writer.WriteBytesFull(ByteArray[2]);
|
|
|
|
|
writer.WriteBytesFull(ByteArray[3]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|