quantum-space-buddies/QSB/ItemSync/Events/MoveToCarryEvent.cs
Mister_Nebula b30490dd4e cleanup
2021-02-25 22:46:31 +00:00

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}");
}
}
}