using UnityEngine.Networking;
namespace Cyber.Networking.Messages {
///
/// Packet containing integers, used in many packet types, such as and .
///
public class IntListPkt : MessageBase {
///
/// List of Integers.
///
public int[] IntList;
///
/// Create a packet containing integers.
///
///
public IntListPkt(int[] idList) {
IntList = idList;
}
///
/// Parameter-less constructor using when deserializing the message.
///
public IntListPkt() {
}
///
/// Used to deserialize a message received via networking.
///
///
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();
IntList = NetworkHelper.DeserializeIntArray(ByteArray);
}
///
/// Used to serialize the message before it is sent.
///
///
public override void Serialize(NetworkWriter writer) {
byte[][] ByteArray = NetworkHelper.SerializeIntArray(IntList);
writer.WriteBytesFull(ByteArray[0]);
writer.WriteBytesFull(ByteArray[1]);
writer.WriteBytesFull(ByteArray[2]);
writer.WriteBytesFull(ByteArray[3]);
}
}
}