mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-06 01:00:16 +00:00
31 lines
1002 B
C#
31 lines
1002 B
C#
using QSB.ItemSync.WorldObjects.Items;
|
|
using QSB.Messaging;
|
|
using QSB.Player;
|
|
using QSB.SectorSync.WorldObjects;
|
|
using QSB.WorldSync;
|
|
using UnityEngine;
|
|
|
|
namespace QSB.ItemSync.Messages;
|
|
|
|
internal class DropItemMessage : QSBWorldObjectMessage<IQSBItem,
|
|
(Vector3 LocalPos, Vector3 LocalNorm, int SectorId)>
|
|
{
|
|
public DropItemMessage(Vector3 position, Vector3 normal, Sector sector) : base((
|
|
sector.transform.InverseTransformPoint(position),
|
|
sector.transform.InverseTransformDirection(normal),
|
|
sector.GetWorldObject<QSBSector>().ObjectId
|
|
)) { }
|
|
|
|
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);
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
player.HeldItem = null;
|
|
player.AnimationSync.VisibleAnimator.SetTrigger("DropHeldItem");
|
|
}
|
|
}
|