# Inventory Manager

<div align="left"><figure><img src="/files/Pxb9F1D6r6SRb7Q5t5rd" alt=""><figcaption></figcaption></figure></div>

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).**

### **How It Works**

1. **Initialization**:
   * Initializes all item slots and prepares the inventory UI for use.
   * `InitializeLoadedInventory` method tries to load inventory data from the relevant save slot.
2. **Item Handling**:
   * **Adding Items**: Items can be added through the relevant item asset or a Gameplay Tag.&#x20;
     * 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.
3. **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.
4. **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.
5. **Saving/Loading**:
   * The `SaveAllInventory` function serializes the inventory state, including items, quantities, and configurations.
   * Inventory data is restored on load using the `InitializeLoadedInventory` function.

### Example Usages

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:

<figure><img src="/files/RITZGNhQONyKO3m6KjWb" alt=""><figcaption></figcaption></figure>

Rest of the functionality is mainly handled by **Inventory Widget.**


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://soulslike-framework.isik.vip/components-managers/player-specific-components/inventory-manager.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
