Hi, I am currently using UCC + UIS, and have set it up such that I have a weapon item AssaultRifle and an ammo item AssaultRifleBullet (ID = 1 for this example) in my main inventory. Once I deplete all my AssaultRifleBullets, it disappears from the inventory. My ammo item category is not unique and not mutable.
When I then go to pick up new AssaultRifleBullet ammo items in an InventoryPickup in the game world, that AssaultRifleBullet gets created with a brand new ID (ID = 2) (e.g. from ObjectPool.Spawn(...)). Therefore, when the Reload ability checks if it ShouldReload(...), it just does a naive check:
This check fails because the AssaultRifleBullet that was picked up has a brand new ID (ID = 2), and it does not match the old ID (ID = 1). My question is: How can I fix this problem? A few things come to mind but it's not clear how to do this.
When I then go to pick up new AssaultRifleBullet ammo items in an InventoryPickup in the game world, that AssaultRifleBullet gets created with a brand new ID (ID = 2) (e.g. from ObjectPool.Spawn(...)). Therefore, when the Reload ability checks if it ShouldReload(...), it just does a naive check:
Code:
reloadableItem.GetReloadableItemIdentifier() != itemIdentifier
This check fails because the AssaultRifleBullet that was picked up has a brand new ID (ID = 2), and it does not match the old ID (ID = 1). My question is: How can I fix this problem? A few things come to mind but it's not clear how to do this.
- ItemCollection actually deals with this okay if the pre-existing AssaultRifleBullet (ID = 1) is still in the inventory. That's because ItemCollection.CanItemStack(...) checks to see if the AssaultRifleBullets are similar and then it adds the new amount to the old amount. The problem is that when the pre-existing AssaultRifleBullet (ID = 1) is no longer in the inventory. This could theoretically be addressed by not removing the item definition even if the amount is zero. But I have no idea how to do this and how much it would break other logic.
- Override any instance where we are doing a naive comparison (e.g. Reload) and force cast it to an Item so that we can call Item.StackableEquivalentTo(...).
- I'm not coming up with any other ideas. Any more elegant way to fix this?