2020-12-16 09:08:38 +00:00
|
|
|
|
using QuantumUNET.Transport;
|
2020-12-15 16:37:52 +00:00
|
|
|
|
using UnityEngine;
|
2020-12-16 08:45:58 +00:00
|
|
|
|
using UnityEngine.Networking;
|
2020-12-02 12:42:26 +00:00
|
|
|
|
|
2020-12-07 21:19:16 +00:00
|
|
|
|
namespace QuantumUNET.Messages
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-23 12:58:45 +00:00
|
|
|
|
internal class QObjectSpawnMessage : QMessageBase
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-16 08:57:15 +00:00
|
|
|
|
public NetworkInstanceId NetId;
|
2021-10-13 18:09:16 +01:00
|
|
|
|
public int assetId;
|
2020-12-03 11:56:32 +00:00
|
|
|
|
public Vector3 Position;
|
|
|
|
|
public byte[] Payload;
|
|
|
|
|
public Quaternion Rotation;
|
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override void Serialize(QNetworkWriter writer)
|
2020-12-16 09:08:38 +00:00
|
|
|
|
{
|
|
|
|
|
writer.Write(NetId);
|
|
|
|
|
writer.Write(assetId);
|
|
|
|
|
writer.Write(Position);
|
|
|
|
|
writer.WriteBytesFull(Payload);
|
|
|
|
|
writer.Write(Rotation);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 12:58:45 +00:00
|
|
|
|
public override void Deserialize(QNetworkReader reader)
|
2020-12-02 12:42:26 +00:00
|
|
|
|
{
|
2020-12-03 11:56:32 +00:00
|
|
|
|
NetId = reader.ReadNetworkId();
|
2021-10-13 18:09:16 +01:00
|
|
|
|
assetId = reader.ReadInt32();
|
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-03 08:28:05 +00:00
|
|
|
|
}
|