/// <summary> /// Initializes specifed container with a set /// </summary> /// <param name="setName"></param> /// <param name="container"></param> public void FillContainer(string setName, SlotContainer <ContainedSlot> container) { SlotContainer <BlueprintSlot> set; if (Config.ContainerSets.TryGetValue(setName, out set)) { if (container.GridSize.X < set.GridSize.X || container.GridSize.Y < set.GridSize.Y) { throw new InvalidOperationException("Destination container is smaller than the set"); } container.Clear(); foreach (var blueprintSlot in set) { try { var item = (Item)CreateFromBluePrint(blueprintSlot.BlueprintId); container.PutItem(item, blueprintSlot.GridPosition, blueprintSlot.ItemsCount); } catch (Exception x) { logger.Error("Unable to create the item from blueprint {0}: {1}", blueprintSlot.BlueprintId, x.Message); } } } }
private bool RollbackItem(ItemTransferMessage itm, Slot slot) { if (slot != null) { var position = itm.SourceContainerSlot; SlotContainer <ContainedSlot> container = null; if (itm.SourceContainerEntityLink.IsPointsTo(this)) { if (itm.SourceContainerSlot.X == -1) { container = Equipment; position.X = 0; } else { container = Inventory; } } if (container != null) { container.PutItem(slot.Item, position, slot.ItemsCount); } else { return(false); } } return(true); }
private void ToolBarSlotClicked(object sender, InventoryWindowCellMouseEventArgs e) { if (_dragControl.Slot == null) { return; } PlayerManager.PlayerCharacter.Toolbar[e.Cell.InventoryPosition.Y] = _dragControl.Slot.Item.BluePrintId; _toolBar.SetSlot(e.Cell.InventoryPosition.Y, new ContainedSlot { Item = _dragControl.Slot.Item, GridPosition = e.Cell.InventoryPosition }); ItemMessageTranslator.SetToolBar(e.Cell.InventoryPosition.Y, _dragControl.Slot.Item.StaticId); _sourceContainer.PutItem(_dragControl.Slot.Item, _dragControl.Slot.GridPosition, _dragControl.Slot.ItemsCount); _guiManager.Screen.Desktop.Children.Remove(_dragControl); _dragControl.Slot = null; _sourceContainer = null; }
public bool PutItems(IItem item, int count) { return(_content.PutItem(item, count)); }