32 lines
1010 B
C#
Raw Normal View History

using QSB.ItemSync.WorldObjects.Items;
2021-12-25 22:35:32 -08: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-02 19:46:33 -08:00
namespace QSB.ItemSync.Messages;
internal class DropItemMessage : QSBWorldObjectMessage<IQSBItem,
(Vector3 LocalPos, Vector3 LocalNorm, int SectorId)>
2021-02-24 10:45:25 +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-02 19:46:33 -08:00
public override void OnReceiveRemote()
{
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-02 19:46:33 -08:00
var player = QSBPlayerManager.GetPlayer(From);
player.HeldItem = WorldObject;
player.AnimationSync.VisibleAnimator.SetTrigger("DropHeldItem");
2021-02-24 10:45:25 +00:00
}
2022-03-04 11:37:24 -08:00
}