# Equipment Window

## 🛡️ EquipmentWindow Class

Window for managing character equipment slots and viewer.

> **Namespace:** `Esper.Inventool.UI`\
> **Access:** `public`\
> **Type:** `class`\
> **Inherits:** `DraggableWindow`

***

### 📦 Fields

| Access          | Field                    | Type                         | Description                            |
| --------------- | ------------------------ | ---------------------------- | -------------------------------------- |
| `protected`     | `equipmentTitle`         | `Label`                      | Equipment window title label.          |
| `protected`     | `characterViewerElement` | `CharacterViewerElement`     | Element for 2D/3D character view.      |
| `protected`     | `equipmentSlotElements`  | `List<EquipmentSlotElement>` | All equipment slot elements.           |
| `protected`     | `slotContainer`          | `VisualElement`              | Container holding slot elements.       |
| `protected`     | `closeButton`            | `Button`                     | Button to close the window.            |
| `public`        | `characterViewer`        | `CharacterViewer`            | Active 3D character viewer component.  |
| `public`        | `rotationResetButton`    | `Button`                     | Button to reset the viewer’s rotation. |
| `public static` | `Instance`               | `EquipmentWindow`            | Active singleton instance.             |

***

### 🔍 Properties

| Access          | Property   | Type              | Description                |
| --------------- | ---------- | ----------------- | -------------------------- |
| `public static` | `Instance` | `EquipmentWindow` | Active singleton instance. |

***

### 🧰 Methods

| Access               | Method                                                                        | Returns                | Description                                                    |
| -------------------- | ----------------------------------------------------------------------------- | ---------------------- | -------------------------------------------------------------- |
| `protected override` | `void Awake()`                                                                | `void`                 | Initialize singleton, UI elements, and event handlers.         |
| `protected override` | `void Start()`                                                                | `void`                 | Apply layout parity, refresh slots, and hide window initially. |
| `protected virtual`  | `void HandleItemEquipped(ItemStack itemStack, EquipmentSlot equipmentSlot)`   | `void`                 | Update slot and inventory when an item is equipped.            |
| `protected virtual`  | `void HandleItemUnequipped(ItemStack itemStack, EquipmentSlot equipmentSlot)` | `void`                 | Update slot and inventory when an item is unequipped.          |
| `public`             | `void LocalizeElements()`                                                     | `void`                 | Localize static UI text when localization is enabled.          |
| `public`             | `void SetCharacterViewer(Sprite sprite)`                                      | `void`                 | Display a 2D sprite in the character viewer.                   |
| `public`             | `void SetCharacterViewer(Texture2D texture)`                                  | `void`                 | Display a 2D texture in the character viewer.                  |
| `public`             | `void SetCharacterViewer()`                                                   | `void`                 | Initialize and display the 3D character viewer if available.   |
| `public virtual`     | `void ResetCharacterViewRotation()`                                           | `void`                 | Smoothly reset the character viewer to its starting rotation.  |
| `public`             | `void RefreshAllEquipmentSlots()`                                             | `void`                 | Refresh visuals for every equipment slot.                      |
| `public`             | `EquipmentSlotElement GetHoveredEquipmentSlotElement()`                       | `EquipmentSlotElement` | Return the equipment slot currently under the pointer.         |
| `public virtual`     | `void Toggle()`                                                               | `void`                 | Toggle window open or closed state.                            |
| `public override`    | `void Open()`                                                                 | `void`                 | Show window, set as active, and invoke open callbacks.         |

## Active Instance

You can get the active `EquipmentWindow` instance with `EquipmentWindow.Instance`. Ensure there's an instance of it in your scene before using this field.

## Opening & Closing

### Open

Call the `Open` method when the player wants to open their equipment.

```csharp
EquipmentWindow.Instance.Open();
```

### Close

`Close` simply closes the window.

```csharp
EquipmentWindow.Instance.Close();
```

### Toggle

Optionally, you can use `Toggle` to open or close the window.

```csharp
EquipmentWindow.Instance.Toggle();
```
