2022-01-14 07:38:45 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.Messaging;
|
2021-12-26 06:04:46 +00:00
|
|
|
|
using QSB.QuantumSync.WorldObjects;
|
2021-12-24 01:07:29 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
2021-01-01 10:17:35 +00:00
|
|
|
|
|
2021-12-24 00:26:31 +00:00
|
|
|
|
namespace QSB.QuantumSync.Messages
|
2021-01-01 10:17:35 +00:00
|
|
|
|
{
|
2021-12-26 06:04:46 +00:00
|
|
|
|
internal class QuantumShuffleMessage : QSBWorldObjectMessage<QSBQuantumShuffleObject>
|
2021-01-01 10:17:35 +00:00
|
|
|
|
{
|
2021-12-26 06:04:46 +00:00
|
|
|
|
private int[] IndexArray;
|
2021-01-01 10:17:35 +00:00
|
|
|
|
|
2021-12-26 06:04:46 +00:00
|
|
|
|
public QuantumShuffleMessage(int[] indexArray) => IndexArray = indexArray;
|
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
2021-01-01 10:17:35 +00:00
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
var temp = IndexArray.Select(x => (byte)x).ToArray();
|
2022-01-14 07:38:45 +00:00
|
|
|
|
writer.WriteBytesAndSize(temp);
|
2021-01-01 10:17:35 +00:00
|
|
|
|
}
|
2021-12-26 06:04:46 +00:00
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
2021-12-26 06:04:46 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
}
|