> For the complete documentation index, see [llms.txt](https://infinitypbr.gitbook.io/magic-pig-games/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://infinitypbr.gitbook.io/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts/panelmanager-1.md).

# BoxManager

v4.0

The `BoxManager` does not have to be a box! It is a thing which holds displayable inventory. This could be a treasure box, or the top of a table, or something else entirely, non physical.

{% hint style="info" %}
In the Party Based RPG demo game, there are `BoxManager` components on the *Lucky Large Treasure Box* and *Small Treasure Box* -- both are in-game objects the player can walk up to and interact with.

There are also `BoxManager` components on *Lucky Treasure Box* and *Small Box Button* -- both of which are UI buttons the player can click on, as a demo.

`BoxManagers` do not have to be physical things in the world!
{% endhint %}

<figure><img src="https://2431624982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MY3N_li2jPq7az6mYfq%2Fuploads%2FTXNCDtS8BcPhTbfpjUGj%2FScreenshot%202023-06-29%20at%209.03.14%20PM.png?alt=media&amp;token=2c588522-ba89-4212-a21b-bf4897d176d5" alt=""><figcaption><p><code>BoxManager</code> from <em>Lucky Large Treasure Box</em> in Party Based RPG demo game</p></figcaption></figure>

## Required data

### Inventory Panel

This is the Prefab with a [`Panel`](/magic-pig-games/game-modules-4/game-module-systems/inventory/scripts/panel.md) on it. Note in the example, which is a prefab you can find in Party Based RPG demo game, I've named the prefab descriptively, including "75px" which refers to the size of the grid boxes -- 75 pixels instead of 100.

### Options

`CanRemoveQuestItems` and `CanReceiveQuestItems` deal with `GameItemObjects` which are marked as `questItem` in the Items module. In some cases, you may not want these special items to be put into certain boxes, where they may become lost from the player.

By default, quest items can be removed, but can not be placed into a `BoxManager`.

## Public Methods

### Add a `GameItemObject` to the list

The `BoxManager` has a `GameItemObjectList` `inventoryItems` on it, which holds the GameItemObjects in the box.

`AddGameItemObjectToList()` will attempt to add a provided `GameItemObject` to that list. It will return `true` if successful, otherwise `false`. Usually `false` would mean the item can't fit in the box.

```csharp
public bool AddGameItemObjectToList(GameItemObject gameItemObject)
```

### Open Inventory

*<mark style="color:green;">You can override this method.</mark>*

This is a method that "opens" the `BoxManager` inventory. You can override it if you'd like to do anything special at this point.

```csharp
public virtual void OpenInventory()

// Example from TreasureBox.cs in the Party Based RPG demo game, which has
// it's own BoxManager component.
_boxManager.OpenInventory();
```
