GridGenerator

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


GRID GENERATOR

Main

  • inventoryGridData: Stores Initial Slot Data Information & Customization about the Player Inventory.

References

  • inventoryManager: Reference to the InventoryProManager (parent of GridGenerator)

  • hotbarParent: Transform that stores all Hotbar Inventory Slots.

  • buttonParent: Transform that stores all Inventory Slots from the Inventory.

  • chestParent: Transform that stores all Chest Inventory Slots. Chests Grid are created dynamically.

Styling & Customization

  • hotbarPadding: Hotbar Spacing from the Inventory

  • gapX: Horizontal Gap/Spacing between Inventory Slots

  • gapY: Vertical Gap/Spacing between Inventory Slots


Getters | GridGenerator.cs

HotbarParent

ChestParent

InventorySlots

HotbarSlots

ChestSlots

CachedChest

Reference to the current open chest.

_InventoryGridData_SO

Rows

Columns

GapX

GapY

HotbarPadding

Functions | GridGenerator.cs

ClearSlotArea(InventorySlot slot)

Clears the entire Area ( From the anchor as the pivot / Origin ) that a slot occupies based on its item size

GatherBulletsInInventory()

Returns all bullets found in the Inventory

ReduceBulletsInInventory(int amount)

Reduce the specified amount of bullets from the Inventory.

AddItemToInventory(Item_SO item_SO, int amount)

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

AddWeaponToInventory(Weapon_SO weapon_SO, int bulletsLeftInmagazine, int totalBullets)

Adds the Given Weapon to the Inventory. Returns true if the weapon has been successfully added to the Inventory.

HasEnoughIngredients(Recipe_SO recipe, int craftAmount)

Returns whether the Player has enough ingredients in the Inventory to afford crafting the given recipe and the given amount.

PayIngredients(Recipe_SO recipe, int craftAmount)

Remove all Items (Ingredients) required by the recipe from the Inventory

IsSlotWithinBounds(int row, int col, Vector2Int itemSize, InventorySlot[,] inventorySlots)

Returns true if the slot fits within the given Inventory bounds.

IsChestFull()

Returns whether the current chest is full or not.

IsInventoryFull()

Returns whether the Player Inventory is full or not.

GetRowAndColumnOutOfIndex(int index)

Converts an index into a tuple representing the corresponding row and column in a grid.

Last updated