using ODMO.Commons.Enums.ClientEnums;
using ODMO.Commons.Models.Base;
using ODMO.Commons.Utils;
using ODMO.Commons.Writers;
namespace ODMO.Commons.Packets.Items
{
public class ReceiveItemPacket : PacketWriter
{
private const int PacketNumber = 3936;
///
/// Receives and highlight a new item to the target inventory.
///
/// The item received.
/// The target inventory enumeration.
/// The affected slot.
public ReceiveItemPacket(ItemModel item, InventoryTypeEnum inventoryType, int slot = 0)
{
Type(PacketNumber);
WriteByte((byte)inventoryType);
WriteByte((byte)item.Slot);
WriteInt(item.ItemId);
WriteShort((short)item.Amount);
WriteByte(0);
if (item.RemainingMinutes() == 4294967280)
{
WriteUInt(item.RemainingMinutes());
}
else
{
var ts = UtilitiesFunctions.RemainingTimeMinutes((int)item.RemainingMinutes());
WriteInt(ts);
}
WriteByte(0);
}
}
}