2022-03-11 05:51:20 +00:00
|
|
|
|
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;
|
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.ItemSync.Messages;
|
|
|
|
|
|
2022-03-11 05:51:20 +00:00
|
|
|
|
internal class DropItemMessage : QSBWorldObjectMessage<IQSBItem,
|
|
|
|
|
(Vector3 LocalPos, Vector3 LocalNorm, int SectorId)>
|
2021-02-24 10:45:25 +00:00
|
|
|
|
{
|
2022-03-11 05:51:20 +00:00
|
|
|
|
public DropItemMessage(Vector3 position, Vector3 normal, Sector sector) : base((
|
|
|
|
|
sector.transform.InverseTransformPoint(position),
|
|
|
|
|
sector.transform.InverseTransformDirection(normal),
|
|
|
|
|
sector.GetWorldObject<QSBSector>().ObjectId
|
|
|
|
|
)) { }
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
2022-03-11 05:51:20 +00:00
|
|
|
|
var sector = Data.SectorId.GetWorldObject<QSBSector>().AttachedObject;
|
|
|
|
|
var position = sector.transform.TransformPoint(Data.LocalPos);
|
|
|
|
|
var normal = sector.transform.TransformDirection(Data.LocalNorm);
|
|
|
|
|
WorldObject.DropItem(position, normal, sector);
|
2022-03-03 03:46:33 +00:00
|
|
|
|
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
2022-03-23 22:26:42 +00:00
|
|
|
|
player.HeldItem = null;
|
2022-03-03 03:46:33 +00:00
|
|
|
|
player.AnimationSync.VisibleAnimator.SetTrigger("DropHeldItem");
|
2021-02-24 10:45:25 +00:00
|
|
|
|
}
|
2022-03-04 19:37:24 +00:00
|
|
|
|
}
|