quantum-space-buddies/QSB/ItemSync/Messages/DropItemMessage.cs

37 lines
961 B
C#
Raw Normal View History

2021-02-24 10:45:25 +00:00
using QSB.Messaging;
using QSB.SectorSync.WorldObjects;
using QSB.WorldSync;
using QuantumUNET.Transport;
using UnityEngine;
namespace QSB.ItemSync.Messages
2021-02-24 10:45:25 +00:00
{
public class DropItemMessage : PlayerMessage
{
public int ObjectId { get; set; }
public Vector3 Position { get; set; }
public Vector3 Normal { get; set; }
public Sector Sector { get; set; }
public override void Deserialize(QNetworkReader reader)
{
base.Deserialize(reader);
ObjectId = reader.ReadInt32();
Position = reader.ReadVector3();
Normal = reader.ReadVector3();
var sectorId = reader.ReadInt32();
Sector = QSBWorldSync.GetWorldFromId<QSBSector>(sectorId).AttachedObject;
}
public override void Serialize(QNetworkWriter writer)
{
base.Serialize(writer);
writer.Write(ObjectId);
writer.Write(Position);
writer.Write(Normal);
2021-11-01 15:49:00 +00:00
var qsbSector = QSBWorldSync.GetWorldFromUnity<QSBSector>(Sector);
2021-02-24 10:45:25 +00:00
writer.Write(qsbSector.ObjectId);
}
}
}