private void OnSlotPut(ContainedSlot slot) { if (slot.Item.PutSound != null) { SoundEngine.StartPlay2D(slot.Item.PutSound); } }
public void SetSlot(int i, ContainedSlot slot) { _toolbarSlots[i].Slot = slot; OnSlotChanged(new InventoryWindowCellMouseEventArgs { Cell = _toolbarSlots[i] }); }
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); }
// 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; }
/// <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 }; }
private void UpdateDrag(ContainedSlot slot) { _dragControl.Slot = slot; _dragControl.BringToFront(); }
private void BeginDrag(ContainedSlot slot) { _dragControl.Slot = slot; _guiManager.Screen.Desktop.Children.Add(_dragControl); _dragControl.BringToFront(); }
private void OnSlotTaken(ContainedSlot slot) { }
/// <summary> /// Allows to control item placement to the grave /// </summary> /// <param name="slot"></param> /// <returns></returns> protected virtual bool OnItemToGrave(ContainedSlot slot) { return(true); }