2022-03-02 19:41:33 -08:00
|
|
|
|
using QSB.ItemSync.WorldObjects.Items;
|
2021-12-25 22:35:32 -08:00
|
|
|
|
using QSB.ItemSync.WorldObjects.Sockets;
|
|
|
|
|
using QSB.Messaging;
|
|
|
|
|
using QSB.Player;
|
|
|
|
|
using QSB.Utility;
|
|
|
|
|
using QSB.WorldSync;
|
2021-02-25 21:24:10 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
namespace QSB.ItemSync.Messages;
|
|
|
|
|
|
|
|
|
|
internal class SocketItemMessage : QSBMessage<(SocketMessageType Type, int SocketId, int ItemId)>
|
2021-02-25 21:24:10 +00:00
|
|
|
|
{
|
2022-03-10 17:57:50 -08:00
|
|
|
|
public SocketItemMessage(SocketMessageType type, int socketId = -1, int itemId = -1) : base((type, socketId, itemId)) { }
|
2022-01-26 13:12:22 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override bool ShouldReceive => QSBWorldSync.AllObjectsReady;
|
2022-01-26 13:12:22 +00:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
public override void OnReceiveRemote()
|
|
|
|
|
{
|
|
|
|
|
QSBItemSocket socketWorldObject;
|
|
|
|
|
IQSBItem itemWorldObject;
|
|
|
|
|
var player = QSBPlayerManager.GetPlayer(From);
|
|
|
|
|
player.HeldItem = null;
|
2021-12-25 22:35:32 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
DebugLog.DebugWrite("DROP HELD ITEM");
|
|
|
|
|
player.AnimationSync.VisibleAnimator.SetTrigger("DropHeldItem");
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
switch (Data.Type)
|
|
|
|
|
{
|
|
|
|
|
case SocketMessageType.Socket:
|
|
|
|
|
socketWorldObject = Data.SocketId.GetWorldObject<QSBItemSocket>();
|
|
|
|
|
itemWorldObject = Data.ItemId.GetWorldObject<IQSBItem>();
|
|
|
|
|
|
|
|
|
|
socketWorldObject.PlaceIntoSocket(itemWorldObject);
|
|
|
|
|
return;
|
|
|
|
|
case SocketMessageType.StartUnsocket:
|
|
|
|
|
socketWorldObject = Data.SocketId.GetWorldObject<QSBItemSocket>();
|
|
|
|
|
|
|
|
|
|
if (!socketWorldObject.IsSocketOccupied())
|
|
|
|
|
{
|
|
|
|
|
DebugLog.ToConsole($"Warning - Trying to start unsocket on socket that is unoccupied! Socket:{socketWorldObject.Name}");
|
2021-12-25 22:35:32 -08:00
|
|
|
|
return;
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|
2022-02-27 04:40:44 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
socketWorldObject.RemoveFromSocket();
|
|
|
|
|
return;
|
|
|
|
|
case SocketMessageType.CompleteUnsocket:
|
|
|
|
|
itemWorldObject = Data.ItemId.GetWorldObject<IQSBItem>();
|
2021-12-25 22:35:32 -08:00
|
|
|
|
|
2022-03-02 19:46:33 -08:00
|
|
|
|
itemWorldObject.OnCompleteUnsocket();
|
|
|
|
|
return;
|
2021-02-25 21:24:10 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-02 19:46:33 -08:00
|
|
|
|
}
|