> For the complete documentation index, see [llms.txt](https://malbersanimations.gitbook.io/animal-controller/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://malbersanimations.gitbook.io/animal-controller/super-item/super-item-system/pouch-manager.md).

# Pouch Manager

## Overview

The **Pouch Manager** holds the character's ammunition: how many of each projectile they carry, and a pooled supply of projectile GameObjects ready to fire.

Ammo belongs to the character, not to the weapon. Two bows share one arrow count; picking up a quiver tops up the character. That is why this component lives next to the Super Item Manager rather than on the item.

Add it with `Malbers ▸ Pouch Manager`.

***

## Requirements

* A `ProjectileID` asset per ammo type.
* An `MProjectile` prefab per ammo type.
* Any item using a [Projectile - Fire](/animal-controller/super-item/super-item-system/item-processors/projectile-fire.md) or [Projectile - Reload](/animal-controller/super-item/super-item-system/item-processors/projectile-reload.md) processor. Without a Pouch Manager those processors disable themselves and warn on equip.

`Reset` seeds the list with a single `Arrow` entry holding 10 rounds.

***

## How it works

On `Awake` the manager creates a `Pouch Pool` GameObject under itself, and one child pool per ammo entry. Each entry builds a Unity `ObjectPool<GameObject>` around its projectile prefab.

When a weapon fires, it asks the pool for an instance rather than instantiating one — which is what keeps a machine gun from allocating. When the projectile finishes, it releases itself back.

{% hint style="warning" %}
Each `ProjectileID` must appear **once**. A duplicate is skipped with a console warning and only the first entry is ever used. The inspector flags duplicates before you hit Play.
{% endhint %}

### Reserve versus magazine

The Pouch holds the **reserve** — the rounds in the character's pockets. A weapon may also have a **Chamber** Stat, the magazine.

| Weapon style       | Configuration                       | Fire consumes                                     |
| ------------------ | ----------------------------------- | ------------------------------------------------- |
| Bow, thrown weapon | No chamber                          | The reserve directly.                             |
| Firearm            | `Use Chamber` on the Fire processor | The Chamber Stat. The reserve is spent at reload. |

That split is why a firearm can be out of magazine but not out of ammo.

***

## Properties

### Infinite Ammo (master switch)

Infinite ammo for **every** projectile in the pouch — a god-mode / debug switch that overrides each entry's own flag. Nothing in the reserve is ever consumed.

It affects the **reserve only**. A weapon that uses a Chamber still empties its magazine and still needs to reload; it simply always has rounds to reload with.

### Invoke Total On Enable

Fire `On Ammo Changed` for every entry on enable, so a UI counter starts with the right number without anything having to spend a round first.

***

### Ammo entry

#### ID

The `ProjectileID` identifying this ammo type. Create one with `Assets ▸ Create ▸ Malbers Animations ▸ ID ▸ Projectile`.

#### Projectile

The `MProjectile` prefab instantiated into the pool.

#### Total

How many the character is carrying. This is the reserve.

#### Infinite

Infinite reserve for **this** projectile alone. The Total is frozen and never decreases, and `Has Ammo` is always satisfied.

An entry is infinite when either its own flag or the pouch's master switch is on. The inspector shows an infinity glyph instead of a Total that will never change. `On Ammo Changed` still fires on every shot, with that frozen value, so a UI bound to it keeps working.

#### Start Pool Size

Instantiate the initial pool up front (disabled) rather than on demand. Turn it on for weapons that fire in bursts, so the first burst does not hitch.

#### Projectile Initial Pool Size

How many instances to pre-create. Default `10`.

#### Projectile Max Pool Size

The pool ceiling. Instances returned beyond it are destroyed rather than kept. Default `50`.

***

## Events

Per ammo entry:

| Event                        | Sends              | Fires when                                                                      |
| ---------------------------- | ------------------ | ------------------------------------------------------------------------------- |
| **On Ammo Changed**          | the new total      | The reserve changed. Also fired once on enable, so a UI counter starts correct. |
| **On Ammo Added Or Removed** | the delta (signed) | Ammo was added (positive) or spent (negative).                                  |

***

## API

```csharp
pouch.Ammo_Add(projectileID);            // add one
pouch.Ammo_Add(projectileID, 20);        // add twenty
pouch.Ammo_Reduce(projectileID, 1);

bool has = pouch.HasAmmo(projectileID);
bool has = pouch.HasAmmo(projectileID, 5, ComparerNumber.GreaterEqual);

// Infinite ammo (UnityEvent friendly)
pouch.Infinite_All(true);                       // the master switch
pouch.Ammo_SetInfinite(projectileID, true);     // one reserve
bool inf = pouch.IsInfinite(projectileID);      // own flag OR master switch

Ammo ammo = pouch.GetProjectile(projectileID);
MProjectile prefab = pouch.GetProjectileObject(projectileID);

ammo.EffectiveTotal;   // int.MaxValue while infinite, so comparers stay meaningful
```

{% hint style="info" %}
`Ammo_Add` with an ID the pouch does not have **creates the entry** and initialises its pool. That is what lets a pickup grant a brand-new ammo type without pre-authoring it on every character.

`Ammo_SetInfinite` does **not** create one — it warns when the entry is missing.
{% endhint %}

***

## Conditions and Reactions

* **`Super Item ▸ Pouch ▸ Has Ammo`** — compares the reserve for a Projectile ID against a value. Use it in an Action's `Conditions On Owner` to stop a dry weapon from firing. An infinite reserve compares as `int.MaxValue`, so it always passes.
* **`Items ▸ Pouch Manager`** reaction — adds or removes ammo, or toggles Infinite for one projectile or the whole pouch. Wire it to a pickup or a debug menu.

***

## Example — an arrow pickup

On the pickup's `Interactable`, an `On Interact` reaction using **Items ▸ Pouch Manager**, Action `Add Amount`, Projectile `Arrow`, Amount `10`.
