Пример #1
0
        private void UnwearItem(WornSlot wslot, byte islot)
        {
            DB_Item item; InventoryItem witem;
            var     index = wslot.Index;

            if (m_wears.TryGetValue(index, out witem))
            {
                if (DataMgr.Select(witem.Id, out item))
                {
                    int itemSlot = islot;
                    if (!GetInventorySlot(islot).IsEmpty)
                    {
                        itemSlot = GetFreeSlot();
                    }
                    if (itemSlot != -1)
                    {
                        if (SetSlot(itemSlot, item, witem, 1) == 0)
                        {
                            m_wears.Remove(index);
                            m_wearSlotsUsed &= ~wslot.Position;
                            m_view.UnwearItem(wslot.Value, m_wearSlotsUsed);
                            if ((item.Flags & ItemFlags.Stats) > 0)
                            {
                                _mPlayer.Stats.UpdateStats();
                            }
                        }
                        else
                        {
                            _player.SystemMsg($"Couldn't unwear item {item.Name}");
                            m_view.WearItem(witem, wslot.Value, m_wearSlotsUsed);
                        }
                    }
                    else
                    {
                        _player.SystemMsg($"You inventory is full");
                        m_view.WearItem(witem, wslot.Value, m_wearSlotsUsed);
                    }
                }
                else
                {
                    _player.SystemMsg($"Item {witem.Id} not found");
                    m_view.WearItem(witem, wslot.Value, m_wearSlotsUsed);
                }
            }
            else
            {
                _player.SystemMsg($"Wear slot {wslot.Position} is empty");
            }
        }
Пример #2
0
        private void UnwearItem(WornSlot wslot, byte islot)
        {
            var index = wslot.Index;

            if (m_wears.TryGetValue(index, out var witem))
            {
                if (DataMgr.Select(witem.Id, out DB_Item item))
                {
                    if (m_items.TryGetValue(islot, out var slot))
                    {
                        var itemSlot = GetFreeSlot();
                        if (itemSlot != -1)
                        {
                            SetSlot(itemSlot, witem, 1);
                            m_wears.Remove(index);
                            m_wearSlotsUsed &= ~wslot.Position;
                            m_view.UnwearItem(wslot.Value, m_wearSlotsUsed);
                            if ((item.Flags & ItemFlags.Stats) > 0)
                            {
                                _mPlayer.Stats.UpdateStats();
                            }
                        }
                        else
                        {
                            _player.SystemMsg($"You inventory is full");
                            m_view.WearItem(witem, wslot.Value, m_wearSlotsUsed);
                        }
                    }
                    else
                    {
                        SetSlot(islot, witem, 1);
                    }
                }
                else
                {
                    _player.SystemMsg($"Item {witem.Id} not found");
                    m_view.WearItem(witem, wslot.Value, m_wearSlotsUsed);
                }
            }
            else
            {
                _player.SystemMsg($"Wear slot {wslot.Position} is empty");
            }
        }