2022-01-14 07:38:45 +00:00
|
|
|
|
using Mirror;
|
|
|
|
|
using QSB.ItemSync.WorldObjects.Items;
|
2021-12-26 06:35:32 +00:00
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
2021-02-24 10:45:25 +00:00
|
|
|
|
using QSB.SectorSync.WorldObjects;
|
|
|
|
|
using QSB.WorldSync;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2021-12-24 00:26:31 +00:00
|
|
|
|
namespace QSB.ItemSync.Messages
|
2021-02-24 10:45:25 +00:00
|
|
|
|
{
|
2021-12-26 06:35:32 +00:00
|
|
|
|
internal class DropItemMessage : QSBWorldObjectMessage<IQSBOWItem>
|
2021-02-24 10:45:25 +00:00
|
|
|
|
{
|
2021-12-26 06:35:32 +00:00
|
|
|
|
private Vector3 Position;
|
|
|
|
|
private Vector3 Normal;
|
|
|
|
|
private int SectorId;
|
2021-02-24 10:45:25 +00:00
|
|
|
|
|
2021-12-26 06:35:32 +00:00
|
|
|
|
public DropItemMessage(Vector3 position, Vector3 normal, Sector sector)
|
2021-02-24 10:45:25 +00:00
|
|
|
|
{
|
2021-12-26 06:35:32 +00:00
|
|
|
|
Position = position;
|
|
|
|
|
Normal = normal;
|
2021-12-26 06:37:20 +00:00
|
|
|
|
SectorId = sector.GetWorldObject<QSBSector>().ObjectId;
|
2021-02-24 10:45:25 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Serialize(NetworkWriter writer)
|
2021-02-24 10:45:25 +00:00
|
|
|
|
{
|
|
|
|
|
base.Serialize(writer);
|
|
|
|
|
writer.Write(Position);
|
|
|
|
|
writer.Write(Normal);
|
2021-12-26 06:35:32 +00:00
|
|
|
|
writer.Write(SectorId);
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-14 07:38:45 +00:00
|
|
|
|
public override void Deserialize(NetworkReader reader)
|
2021-12-26 06:35:32 +00:00
|
|
|
|
{
|
|
|
|
|
base.Deserialize(reader);
|
|
|
|
|
Position = reader.ReadVector3();
|
|
|
|
|
Normal = reader.ReadVector3();
|
2022-01-14 07:38:45 +00:00
|
|
|
|
SectorId = reader.Read<int>();
|
2021-12-26 06:35:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
2021-12-26 06:37:20 +00:00
|
|
|
|
var sector = SectorId.GetWorldObject<QSBSector>().AttachedObject;
|
2021-12-26 06:35:32 +00:00
|
|
|
|
WorldObject.DropItem(Position, Normal, sector);
|
|
|
|
|
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.HeldItem = WorldObject;
|
2021-02-24 10:45:25 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|