mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2025-01-09 21:59:16 +00:00
36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using QSB.Events;
|
|
using QSB.ItemSync.WorldObjects;
|
|
using QSB.Player;
|
|
using QSB.Utility;
|
|
using QSB.WorldSync;
|
|
using QSB.WorldSync.Events;
|
|
|
|
namespace QSB.ItemSync.Events
|
|
{
|
|
internal class MoveToCarryEvent : QSBEvent<WorldObjectMessage>
|
|
{
|
|
public override EventType Type => EventType.MoveToCarry;
|
|
|
|
public override void SetupListener()
|
|
=> GlobalMessenger<int>.AddListener(EventNames.QSBMoveToCarry, Handler);
|
|
|
|
public override void CloseListener()
|
|
=> GlobalMessenger<int>.RemoveListener(EventNames.QSBMoveToCarry, Handler);
|
|
|
|
private void Handler(int itemId)
|
|
=> SendEvent(CreateMessage(itemId));
|
|
|
|
private WorldObjectMessage CreateMessage(int itemid) => new WorldObjectMessage
|
|
{
|
|
AboutId = QSBPlayerManager.LocalPlayerId,
|
|
ObjectId = itemid
|
|
};
|
|
|
|
public override void OnReceiveRemote(bool server, WorldObjectMessage message)
|
|
{
|
|
var itemObject = QSBWorldSync.GetWorldFromId<IQSBOWItem>(message.ObjectId);
|
|
DebugLog.DebugWrite($"Pretend we pick up item {(itemObject as IWorldObject).Name} for player {message.FromId}");
|
|
}
|
|
}
|
|
}
|