Inventory Manager
Last updated
Was this helpful?
Last updated
Was this helpful?
The Inventory Manager (AC_InventoryManager) provides all the necessary functionality to handle player Inventory & Storage, including adding, removing, and using items, managing currency, and updating the UI in runtime.
It is added to the PlayerController class by default (PC_SoulslikeFramework).
Initialization:
Initializes all item slots and prepares the inventory UI for use.
InitializeLoadedInventory
method tries to load inventory data from the relevant save slot.
Item Handling:
Adding Items: Items can be added through the relevant item asset or a Gameplay Tag.
Automatically increments quantity if the item already exists, or creates a new slot if it doesn’t.
Removing Items: Removes a specific quantity or deletes the item from the inventory entirely.
Using Items: Triggers the item’s OnUse
function, spawning the appropriate actor (e.g., potion, consumable) and applying effects.
Triggering Actions: Triggers the item's provided ActionTag
, queueing it through the Input Buffer.
Inventory Queries:
Supports multiple ways to query inventory data:
HasItem: Checks if a specific item is present.
GetAmountOfItemWithTag: Retrieves the quantity of items matching a specific tag.
GetEmptySlot: Finds the next available empty inventory slot.
UI Updates:
Event dispatchers such as OnInventoryUpdated
and OnCurrencyUpdated
ensure the inventory UI is always in sync with changes.
The GetInventoryWidget
function links the UI directly to the inventory component.
Saving/Loading:
The SaveAllInventory
function serializes the inventory state, including items, quantities, and configurations.
Inventory data is restored on load using the InitializeLoadedInventory
function.
The provided Parent Door Class (B_Door) has a great example on utilizing the Inventory Manager for checking if multiple key items (e.g, KeyA x1 & KeyB x4) exist in inventory before unlocking a door:
Rest of the functionality is mainly handled by Inventory Widget.