CharacterInventoryBridge [Feature Request]

Exi-G

New member
Hi, I'd like to request for you to make the m_AmmoItemCollectionName field in CharacterInventoryBridge an array of strings instead of a single string. The reason for this is, I have a complex inventory which uses multiple item collections and an ammo can be in any of these item collection. by default the m_AmmoItemCollectionName value is Default and i am using the Default item collection as an ItemTransactionCollection so if i pick up a shootable weapon with ammo and equip the weapon, then it shoes that ammo is 0 even though the ammo is visible in one of the inventory collections (i.e. Backpack, Vest, Shirt and Pants). This is because the ammo is expected to be in the Default ItemCollection but the Default ItemCollection is used as Transaction to distribute item to other item collections.

Here is a screenshot of my inventory component:
1629660054529.png

And here is a screenshot of my inventory system in game:
1629660190649.png

I have solved this issue by making the m_AmmoItemCollectionName an array of string and adding the item collections i want to contain the ammo in the list:
1629660362133.png
Everything works fine. The reason I want to request this to be added in the next update is because I might loose my changes when I update the package and i don't want to always make the same change every time i update the package. Here are the changes i made in the CharacterInventoryBridge to get this working:

I changed
C#:
[SerializeField] protected string m_AmmoItemCollectionName = "Default";
to
C#:
[SerializeField] protected string[] m_AmmoItemCollectionName = new []{"Default"};

I changed
C#:
private ItemCollection m_AmmoItemCollection;
to
C#:
private ItemCollectionGroup m_AmmoItemCollection;
I changed
C#:
m_AmmoItemCollection = GetItemCollection(m_AmmoItemCollectionName, true); // on line 127
to
C#:
m_AmmoItemCollection = new ItemCollectionGroup { ItemCollections = new List<ItemCollection>() };
foreach (var collectionName in m_AmmoItemCollectionName) {
    var ammoCollection = GetItemCollection(collectionName, true);
    if (ammoCollection == null) { continue; }
    m_AmmoItemCollection.ItemCollections.Add(ammoCollection);
}

I also changed
C#:
if (destinationItemCollection == m_AmmoItemCollection) // On line 240
to
C#:
if (m_AmmoItemCollection.ItemCollections.Contains(destinationItemCollection))

And finally i changed
C#:
m_AmmoItemCollection.RemoveItem(item, -amount); // Line 871
to
C#:
var ammoItemInfo = m_AmmoItemCollection.GetItemInfo(item);
ammoItemInfo.Value.ItemCollection.RemoveItem(item, -amount);

I hope you can add this in for the next update
 
Thank you fo the detailed request. I completely agree with your changes, I've implemented them and they will be part of the next update.
I just renamed the field and variables to be pural: "m_AmmoItemCollectionNames", "m_AmmoItemCollections", etc...
 
Top