quantum-space-buddies/QuantumUNET/QSBObjectSpawnMessage.cs
2020-12-04 22:14:53 +00:00

35 lines
813 B
C#

using UnityEngine;
using UnityEngine.Networking;
namespace QuantumUNET
{
internal class QSBObjectSpawnMessage : QSBMessageBase
{
public NetworkInstanceId NetId;
public NetworkHash128 assetId;
public Vector3 Position;
public byte[] Payload;
public Quaternion Rotation;
public override void Deserialize(QSBNetworkReader reader)
{
NetId = reader.ReadNetworkId();
assetId = reader.ReadNetworkHash128();
Position = reader.ReadVector3();
Payload = reader.ReadBytesAndSize();
if (reader.Length - reader.Position >= 16U)
{
Rotation = reader.ReadQuaternion();
}
}
public override void Serialize(QSBNetworkWriter writer)
{
writer.Write(NetId);
writer.Write(assetId);
writer.Write(Position);
writer.WriteBytesFull(Payload);
writer.Write(Rotation);
}
}
}