Inventory Architecture

Main Inventory Backend
In Ferrus, the character's main inventory functions as an Array of ACommissarItem child class instances (populated by blueprint instances). This array contains individual items and stackable items (marked with a boolean bIsStackable).

It has a simple getter method, GetInventory, exposed publically and is mainly interacted with by the player's class, which adds items to it and can invoke items to be dropped. When an item is used - and it reaches 0 uses (if applicable), the item removes itself from the inventory array and destroys itself.

Stacking is fairly simple, too. When trying to add stackable items to the player's inventory, the code will first try to look and see if that item exists - if not, it is simply added to the inventory. If it does, then the item itself is discarded since the item that's already in will have an integer variable - StackCount - incremented by 1. The code will then check, whenever an item's uses variable hits 0, if it is a) stackable and b) if it has stacks above 1. If both are yes, then the uses are restored to the maximum until the item stack is exhausted.