Ejemplo n.º 1
0
        private void DidCloseLootRandomizer(ItemSlot slot, GuiDialogGeneric dialog)
        {
            dialogs.Remove(slot);
            if (slot.Itemstack == null)
            {
                return;
            }

            if (dialog.Attributes.GetInt("save") == 0)
            {
                return;
            }

            foreach (var val in dialog.Attributes)
            {
                slot.Itemstack.Attributes[val.Key] = val.Value;
            }

            using (MemoryStream ms = new MemoryStream())
            {
                BinaryWriter writer = new BinaryWriter(ms);
                slot.Itemstack.Attributes.ToBytes(writer);

                clientChannel.SendPacket(new SaveLootRandomizerAttributes()
                {
                    attributes  = ms.ToArray(),
                    InventoryId = slot.Inventory.InventoryID,
                    SlotId      = slot.Inventory.GetSlotId(slot)
                });
            }
        }
Ejemplo n.º 2
0
        private void DidCloseStackRandomizer(ItemSlot slot, GuiDialogGeneric dialog)
        {
            dialogs.Remove(slot);
            if (slot.Itemstack == null)
            {
                return;
            }

            if (dialog.Attributes.GetInt("save") == 0)
            {
                return;
            }

            slot.Itemstack.Attributes.SetFloat("totalChance", dialog.Attributes.GetFloat("totalChance"));

            using (MemoryStream ms = new MemoryStream())
            {
                BinaryWriter writer = new BinaryWriter(ms);
                slot.Itemstack.Attributes.ToBytes(writer);

                clientChannel.SendPacket(new SaveStackRandomizerAttributes()
                {
                    TotalChance = dialog.Attributes.GetFloat("totalChance"),
                    InventoryId = slot.Inventory.InventoryID,
                    SlotId      = slot.Inventory.GetSlotId(slot)
                });
            }
        }