예제 #1
0
        private void WearItem(WornSlot wslot, byte islot)
        {
            DB_Item item; InventoryItem witem;
            var     itemSlot = GetSlot(islot);

            if (itemSlot?.IsEmpty ?? true)
            {
                _player.SystemMsg($"Inventory slot {islot} is empty");
            }
            else
            {
                if (DataMgr.Select(itemSlot.Item.Id, out item))
                {
                    var wPosition = wslot.Position;
                    if ((item.Slot & wPosition) == wPosition)
                    {
                        var flags = item.Flags;
                        var index = wslot.Index;
                        m_items.Remove(islot);
                        m_view.UpdateSlot(itemSlot.Delete(), islot);
                        if (m_wears.TryGetValue(index, out witem))
                        {
                            item = DataMgr.SelectItem(witem.Id);
                            SetSlot(islot, item, witem, 1);
                            flags |= item.Flags;
                        }
                        m_wearSlotsUsed |= wPosition;
                        m_wears[index]   = itemSlot.Item;
                        m_view.WearItem(itemSlot.Item, wslot.Value, m_wearSlotsUsed);
                        if ((flags & ItemFlags.Stats) > 0)
                        {
                            _mPlayer.Stats.UpdateStats();
                        }
                    }
                    else
                    {
                        _player.SystemMsg($"You can't wear {item.Name} in {wPosition}");
                    }
                }
                else
                {
                    _player.SystemMsg($"Item {itemSlot.Item.Id} not found");
                }
            }
        }