# Storage Keeper

## 🛠️ StorageKeeper Class

Provides item storage functionality to a GameObject.

> **Namespace:** `Esper.Inventool.Storing`&#x20;
>
> **Access:** `public`&#x20;
>
> **Type:** `class`&#x20;
>
> **Inherits:** `MonoBehaviour`

***

### 📦 Fields

| Access          | Field                 | Type            | Description                                                                |
| --------------- | --------------------- | --------------- | -------------------------------------------------------------------------- |
| `public`        | `storage`             | `Storage`       | The storage instance managed by this keeper.                               |
| `private`       | `inRangeIndicator`    | `GameObject`    | Object enabled when the player is in range of the storage keeper.          |
| `public`        | `interactionAction`   | `Action`        | The action invoked when `Interact()` is called.                            |
| `public static` | `activeStorageKeeper` | `StorageKeeper` | The storage keeper the player is currently in range of, or `null` if none. |

***

### 🧰 Methods

| Access              | Method                                   | Returns | Description                                                                       |
| ------------------- | ---------------------------------------- | ------- | --------------------------------------------------------------------------------- |
| `protected virtual` | `Awake()`                                | `void`  | Initializes the keeper, sets `interactionAction = OpenWindow`, and loads storage. |
| `private`           | `OnDestroy()`                            | `void`  | Clears storage when the object is destroyed.                                      |
| `private`           | `OnApplicationQuit()`                    | `void`  | Clears storage when the application quits.                                        |
| `public`            | `OpenWindow()`                           | `void`  | Opens the storage window using available UI implementation.                       |
| `public`            | `Interact()`                             | `void`  | Invokes the assigned `interactionAction`.                                         |
| `private`           | `OnTriggerEnter(Collider other)`         | `void`  | Activates indicator and sets `activeStorageKeeper` when player enters range.      |
| `private`           | `OnTriggerEnter2D(Collider2D collision)` | `void`  | Same as above, for 2D colliders.                                                  |
| `private`           | `OnTriggerExit(Collider other)`          | `void`  | Deactivates indicator, clears `activeStorageKeeper`, and closes/exits UI.         |
| `private`           | `OnTriggerExit2D(Collider2D collision)`  | `void`  | Same as above, for 2D colliders.                                                  |

## Active Storage Keeper

You can get the storage keeper the player is currently in range of with the `Storage.activeStorageKeeper` field. This will be null if the player is not in range of a storage keeper.

## Interact

You can interact with the storage keeper with the `Interact` method. By default, the interact method invokes the `interactionAction` method which is set to the `OpenInventoolWindow` method.
