# GridGenerator

GridGenerator Handles Generation, Population and Management of all grids in Inventory Pro Manager Add-On, including Inventory + Chests.

***

### GRID GENERATOR

#### Main

* <mark style="color:purple;">inventoryGridData:</mark> Stores Initial Slot Data Information & Customization about the Player Inventory.

#### References

* <mark style="color:purple;">inventoryManager:</mark> Reference to the InventoryProManager (parent of GridGenerator)
* <mark style="color:purple;">hotbarParent:</mark> Transform that stores all Hotbar Inventory Slots.
* <mark style="color:purple;">buttonParent:</mark> Transform that stores all Inventory Slots from the Inventory.
* <mark style="color:purple;">chestParent:</mark> Transform that stores all Chest Inventory Slots. Chests Grid are created dynamically.

#### Styling & Customization

* <mark style="color:purple;">hotbarPadding:</mark> Hotbar Spacing from the Inventory
* <mark style="color:purple;">gapX:</mark> Horizontal Gap/Spacing between Inventory Slots
* <mark style="color:purple;">gapY:</mark> Vertical Gap/Spacing between Inventory Slots

***

### Getters | GridGenerator.cs&#x20;

> <mark style="color:orange;">HotbarParent</mark>

> <mark style="color:orange;">ChestParent</mark>

> <mark style="color:orange;">InventorySlots</mark>

> <mark style="color:orange;">HotbarSlots</mark>

> <mark style="color:orange;">ChestSlots</mark>

> <mark style="color:orange;">CachedChest</mark>
>
> Reference to the current open chest.

> *<mark style="color:orange;">\_InventoryGridData\_SO</mark>*

> <mark style="color:orange;">Rows</mark>

> <mark style="color:orange;">Columns</mark>

> <mark style="color:orange;">GapX</mark>

> <mark style="color:orange;">GapY</mark>

> <mark style="color:orange;">HotbarPadding</mark>

### Functions | GridGenerator.cs&#x20;

> <mark style="color:green;">ClearSlotArea(InventorySlot slot)</mark>
>
> Clears the entire Area ( From the anchor as the pivot / Origin ) that a slot occupies based on its item size

> <mark style="color:green;">GatherBulletsInInventory()</mark>
>
> Returns all bullets found in the Inventory

> <mark style="color:green;">ReduceBulletsInInventory(int amount)</mark>
>
> Reduce the specified amount of bullets from the Inventory.

> <mark style="color:green;">AddItemToInventory(Item\_SO item\_SO, int amount)</mark>
>
> Adds the Given Item to the Inventory. Returns (bool success, int amount): success is true if the entire amount of the item has been successfully added to the Inventory.> \
> If success is true, amount equals 0. If success is false, amount will return the amount of Items that were not added to the Inventory

> <mark style="color:green;">AddWeaponToInventory(Weapon\_SO weapon\_SO, int bulletsLeftInmagazine, int totalBullets)</mark>
>
> Adds the Given Weapon to the Inventory. Returns true if the weapon has been successfully added to the Inventory.

> <mark style="color:green;">HasEnoughIngredients(Recipe\_SO recipe, int craftAmount)</mark>
>
> Returns whether the Player has enough ingredients in the Inventory to afford crafting the given recipe and the given amount.

> <mark style="color:green;">PayIngredients(Recipe\_SO recipe, int craftAmount)</mark>
>
> Remove all Items (Ingredients) required by the recipe from the Inventory

> <mark style="color:green;">IsSlotWithinBounds(int row, int col, Vector2Int itemSize, InventorySlot\[,] inventorySlots)</mark>
>
> Returns true if the slot fits within the given Inventory bounds.

> <mark style="color:green;">IsChestFull()</mark>
>
> Returns whether the current chest is full or not.

> <mark style="color:green;">IsInventoryFull()</mark>
>
> Returns whether the Player Inventory is full or not.

> <mark style="color:green;">GetRowAndColumnOutOfIndex(int index)</mark>
>
> Converts an index into a tuple representing the corresponding row and column in a grid.
