The Close method is not called after all items have been removed from the chest

EVG

Member
The video shows that the Close method is no longer called when you click on the Cancel or Take All button after all items have been taken from the chest. Why is this happening and how to solve it? I don't use chest animations.
 

Attachments

  • Chest.png
    Chest.png
    260.3 KB · Views: 2
Found the if (m_Chest.Inventory.MainItemCollection.GetAllItemStacks().Count != 0) condition in the ChestMenu class. How important is this condition? Can I remove it without consequences?
 
It shouldn't be important.
Please find the update chest menu. I've made it optional to keep the chest open if it is empty
 

Attachments

  • ChestMenu.cs
    7.9 KB · Views: 1
  • Like
Reactions: EVG
It shouldn't be important.
Please find the update chest menu. I've made it optional to keep the chest open if it is empty
I also noticed such a problem when integrating with FPC. When I take an item from the chest that should be equipped, after taking it, it is not equipped, as it is added to the MainItemCollection, although it should be added to Equippable.
 
I see... that option to add it somewhere else is missing.

Please find the updated ChestMenu script which allows you to define the itemCollection where the items should be added to.
I've made a few functions virtual such that the ChestMenu can easily be overriden for custom stuff.

Note that you could have also used a ItemTransactionCollection as your main item collection. It's worth giving this a read:
 

Attachments

  • ChestMenu.cs
    8.6 KB · Views: 2
  • Like
Reactions: EVG
I'm trying to override the method of taking all items from the chest for different collections. Everything seems to be working well, but now the UI has no information about the picked up item that needs to be equipped, there is only information about the item from the main collection. Why is that?

C#:
    protected override void TakeAllItems()
    {
        var clientItemCollection = m_Inventory.GetItemCollection(m_AddToItemCollectionName);
        var equippableClientItemCollection = m_Inventory.GetItemCollection("Equippable Slots");
        if (clientItemCollection == null)
        {
            clientItemCollection = m_Inventory.MainItemCollection;
        }



        // Get all the item infos in the item collection, requires an array.
        var pooledArray = GenericObjectPool.Get<Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo[]>();
        var allItemInfos = m_Chest.Inventory.MainItemCollection.GetAllItemInfos(ref pooledArray);
        for (int i = 0; i < allItemInfos.Count; i++)
        {
            var itemInfo = allItemInfos[i];
            var item = itemInfo.Item;
            // Do nothing if the item is null ( it shouldn't be null )
            if (item == null) { continue; }

            if (characterInventoryBridge.EquippableCategory.InherentlyContains(item))
                m_Chest.Inventory.MainItemCollection.GiveItem(itemInfo, equippableClientItemCollection, null);
            else
                m_Chest.Inventory.MainItemCollection.GiveItem(itemInfo, clientItemCollection, null);
        }
        // IMPORTANT: make sure to return the pooled array once you finished using it.
        GenericObjectPool.Return(pooledArray);

        //m_Chest.Inventory.MainItemCollection.GiveAllItems(
        //    clientItemCollection, null);

        m_DisplayPanel.Close();
    }
 

Attachments

  • inv.png
    inv.png
    240.1 KB · Views: 3
The Inventory Monitor component is the one that shows the item popup.
By default it only monitors items being added to the Main ItemCollection if none is specified.
But you can add any collection you want to the list to monitor
1668154933398.png
So you should probably add the main and equippable collection name in that list
 
  • Like
Reactions: EVG
Top