Пример #1
0
 private void OnSlotPut(ContainedSlot slot)
 {
     if (slot.Item.PutSound != null)
     {
         SoundEngine.StartPlay2D(slot.Item.PutSound);
     }
 }
Пример #2
0
        public void SetSlot(int i, ContainedSlot slot)
        {
            _toolbarSlots[i].Slot = slot;

            OnSlotChanged(new InventoryWindowCellMouseEventArgs {
                Cell = _toolbarSlots[i]
            });
        }
Пример #3
0
        private bool TakeItem(ItemTransferMessage itemTransferMessage, out ContainedSlot slot)
        {
            slot = null;

            var position = itemTransferMessage.SourceContainerSlot;
            var srcLink  = itemTransferMessage.SourceContainerEntityLink;

            // item from nowhere
            if (srcLink.IsEmpty)
            {
                slot = new ContainedSlot {
                    Item       = (IItem)EntityFactory.CreateFromBluePrint((ushort)itemTransferMessage.ItemEntityId),
                    ItemsCount = itemTransferMessage.ItemsCount
                };
                return(true);
            }

            // detect the container
            var container = FindContainer(srcLink, position, out position);

            if (container == null)
            {
                return(false);
            }

            slot = container.PeekSlot(position);

            if (!container.TakeItem(position, itemTransferMessage.ItemsCount))
            {
                slot = null;
                return(false);
            }

            slot.ItemsCount = itemTransferMessage.ItemsCount;

            if (!itemTransferMessage.IsSwitch && container == Inventory)
            {
                var pos           = itemTransferMessage.DestinationContainerSlot;
                var destContainer = FindContainer(itemTransferMessage.DestinationContainerEntityLink, itemTransferMessage.DestinationContainerSlot, out pos);

                if (destContainer == Equipment)
                {
                    ActiveToolInventoryPosition = itemTransferMessage.SourceContainerSlot;
                }
            }

            return(true);
        }
Пример #4
0
        // handling player inventory requests
        private void InventoryItemTaken(object sender, EntityContainerEventArgs <ContainedSlot> e)
        {
            if (!Enabled)
            {
                return;
            }

            if (_skipInventoryEvents)
            {
                return;
            }

            // at this point we need to remember what was taken to create appropriate message
            if (_pendingOperation)
            {
                throw new InvalidOperationException("Unable to take another item, release first previous taken item");
            }

            _tempSlot         = e.Slot;
            _pendingOperation = true;
            _sourceContainer  = (ISlotContainer <ContainedSlot>)sender;
        }
Пример #5
0
        /// <summary>
        /// Takes currently locked item from the world
        /// </summary>
        public void TakeFromWorld()
        {
            if (_pendingOperation)
            {
                throw new InvalidOperationException("Unable to take another item, release first previous taken item");
            }

            if (_lockedEntity == null)
            {
                throw new InvalidOperationException("Lock world item before trying to take it");
            }

            if (!(_lockedEntity is IItem))
            {
                throw new InvalidOperationException("Locked entity should implement IItem interface");
            }

            _pendingOperation = true;
            _sourceContainer  = null;
            _tempSlot         = new ContainedSlot {
                Item = (IItem)_lockedEntity, ItemsCount = 1
            };
        }
Пример #6
0
 private void UpdateDrag(ContainedSlot slot)
 {
     _dragControl.Slot = slot;
     _dragControl.BringToFront();
 }
Пример #7
0
 private void BeginDrag(ContainedSlot slot)
 {
     _dragControl.Slot = slot;
     _guiManager.Screen.Desktop.Children.Add(_dragControl);
     _dragControl.BringToFront();
 }
Пример #8
0
 private void OnSlotTaken(ContainedSlot slot)
 {
 }
Пример #9
0
 /// <summary>
 /// Allows to control item placement to the grave
 /// </summary>
 /// <param name="slot"></param>
 /// <returns></returns>
 protected virtual bool OnItemToGrave(ContainedSlot slot)
 {
     return(true);
 }