2021-12-25 22:04:46 -08:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.QuantumSync.WorldObjects;
|
2021-12-23 16:26:31 -08:00
|
|
|
|
using QuantumUNET.Transport;
|
2021-12-23 17:07:29 -08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2021-01-01 10:17:35 +00:00
|
|
|
|
|
2021-12-23 16:26:31 -08:00
|
|
|
|
namespace QSB.QuantumSync.Messages
|
2021-01-01 10:17:35 +00:00
|
|
|
|
{
|
2021-12-25 22:04:46 -08:00
|
|
|
|
internal class QuantumShuffleMessage : QSBWorldObjectMessage<QSBQuantumShuffleObject>
|
2021-01-01 10:17:35 +00:00
|
|
|
|
{
|
2021-12-25 22:04:46 -08:00
|
|
|
|
private int[] IndexArray;
|
2021-01-01 10:17:35 +00:00
|
|
|
|
|
2021-12-25 22:04:46 -08:00
|
|
|
|
public QuantumShuffleMessage(int[] indexArray) => IndexArray = indexArray;
|
|
|
|
|
|
2021-01-01 10:17:35 +00:00
|
|
|
|
public override void Serialize(QNetworkWriter writer)
|
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
var temp = IndexArray.Select(x => (byte)x).ToArray();
|
|
|
|
|
writer.WriteBytesAndSize(temp, temp.Length);
|
|
|
|
|
}
|
2021-12-25 22:04:46 -08:00
|
|
|
|
|
|
|
|
|
public override void Deserialize(QNetworkReader reader)
|
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
IndexArray = Array.ConvertAll(reader.ReadBytesAndSize(), Convert.ToInt32);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote() => WorldObject.ShuffleObjects(IndexArray);
|
2021-01-01 10:17:35 +00:00
|
|
|
|
}
|
|
|
|
|
}
|