2020-12-02 21:23:01 +00:00
|
|
|
|
using UnityEngine;
|
2020-12-02 12:42:26 +00:00
|
|
|
|
using UnityEngine.Networking;
|
|
|
|
|
|
2020-12-04 22:14:53 +00:00
|
|
|
|
namespace QuantumUNET
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-04 09:23:27 +00:00
|
|
|
|
internal class QSBObjectSpawnMessage : QSBMessageBase
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-03 11:56:32 +00:00
|
|
|
|
public NetworkInstanceId NetId;
|
|
|
|
|
public NetworkHash128 assetId;
|
|
|
|
|
public Vector3 Position;
|
|
|
|
|
public byte[] Payload;
|
|
|
|
|
public Quaternion Rotation;
|
|
|
|
|
|
2020-12-04 09:23:27 +00:00
|
|
|
|
public override void Deserialize(QSBNetworkReader reader)
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-03 11:56:32 +00:00
|
|
|
|
NetId = reader.ReadNetworkId();
|
2020-12-02 12:42:26 +00:00
|
|
|
|
assetId = reader.ReadNetworkHash128();
|
2020-12-03 11:56:32 +00:00
|
|
|
|
Position = reader.ReadVector3();
|
|
|
|
|
Payload = reader.ReadBytesAndSize();
|
|
|
|
|
if (reader.Length - reader.Position >= 16U)
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-03 11:56:32 +00:00
|
|
|
|
Rotation = reader.ReadQuaternion();
|
2020-12-02 12:42:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-04 09:23:27 +00:00
|
|
|
|
public override void Serialize(QSBNetworkWriter writer)
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-03 11:56:32 +00:00
|
|
|
|
writer.Write(NetId);
|
2020-12-02 12:42:26 +00:00
|
|
|
|
writer.Write(assetId);
|
2020-12-03 11:56:32 +00:00
|
|
|
|
writer.Write(Position);
|
|
|
|
|
writer.WriteBytesFull(Payload);
|
|
|
|
|
writer.Write(Rotation);
|
2020-12-02 12:42:26 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-03 08:28:05 +00:00
|
|
|
|
}
|