Get Item Identifier Amount To Work with UIS

The task uses an ItemTpe which the inventory system isn't aware of. ItemIdentifiers are regular objects so you can't just replace the ItemType declaration. With the Deathmatch AI Kit I get around this by using an ItemDefinition and then retrieving the ItemIdentifier based off of that definition. Maybe @Sangemdoko has some ideas.
 
I've given your method a try and no dice. I tried adding an item script with the ItemDefinition but its not registering on the BD side. I wonder if @Sangemdoko has any thoughts.

If not I am have to pick up the Deathmatch AI kit and see how you did.
 
Unfortunately I think the best way would be to create a new Task that uses an Item Definition instead of an ItemType.

Another idea that just came to mind, what if we use the name of the ItemType to find the matching ItemDefinition inside the GetItemIdentifierInternalFunction? From there we could find the first item in the Inventory that matches the ItemDefinition (maybe even giving priority to the equipped items).
I'm not very familiar with ItemTypes so it may not be possible.

Something around those lines (replaced in UltimateInventorySystemBridge.cs line 890)
Code:
        /// <summary>
        /// Internal method which returns the amount of the specified ItemIdentifier.
        /// </summary>
        /// <param name="itemIdentifier">The ItemIdentifier to get the amount of.</param>
        /// <returns>The amount of the specified ItemIdentifier.</returns>
        protected override int GetItemIdentifierAmountInternal(IItemIdentifier itemIdentifier)
        {
            if (itemIdentifier is ItemType) {
                //Debug.LogError($"Error: The ItemIdentifier {itemIdentifier} is an ItemType. The identifier must be created by the Ultimate Inventory System.");
                //return 0;
                var itemDefinition = itemIdentifier.GetItemDefinition();
                var itemInfo = m_Inventory.GetItemInfo(itemDefinition as ItemDefinition);
                if (itemInfo.HasValue == false) { return 0; }

                itemIdentifier = itemInfo.Value.Item;
            }
#if UNITY_EDITOR
            if (!m_InventorySytemManager.Database.Contains(itemIdentifier as Opsive.UltimateInventorySystem.Core.Item)) {
                Debug.LogError($"Error: The Item ({itemIdentifier}) does not exist within the active database ({m_InventorySytemManager.Database.name}).");
                return 0;
            }
#endif

            var item = itemIdentifier as Opsive.UltimateInventorySystem.Core.Item;
            if (item?.ItemCollection == null) {
                return m_DefaultItemCollection.GetItemAmount(item);
            }
            return item.ItemCollection.GetItemAmount(item);
        }

If this works let us know and we can polish it a bit and add it in the next update
 
Thanks for the input @Sangemdoko but I think creating a new task that deals with UIS' Item Definition is the way to go because if I change the UltimateInventorySystemBridge script I still have to do all the things that Justin did. Seems like more steps to get to the same place, unless I'm missing something.

I will try to write a new task and see what I can come up with.

Thanks again!
 
Top