Inventory

What is a JcInventoryCore
A JcInventory is a actor that holds an array full of items. It also has many inbuilt functions and helpers for modifying the array and displaying the array. It is the backbone of the JcInventory system.

The Items array
The ItemSlots array is made up of JCSlot Struct's, The JcSlot Struct is made up of 3 variables, The quantity of items in the slot, the item data that is in the slot, and the parent index.

The parent index is only set if the item slot is invalid because another item is overlapping the slot. The sysem uses basic math to convert a 1d array into a 2d array, however we know that items can be bigger then one slot. When an item is bigger then a slot, it will set all of its overlapping slots parent index to its own index.

For example, a box the size of 2 x 2 is placed in ItemSlots[0], then we would use

ItemSlots[Grid to index(0,0)].parentindex = 0; //We set it to 0 because the item data is at index 0.

ItemSlots[Grid to index(0,1)].parentindex = 0;

ItemSlots[Grid to index(1,0)].parentindex = 0;

ItemSlots[Grid to index(1,1)].parentindex = 0;

To explain this, read up on Grid To Index, and Index To Grid.

All the helper functions in the JcInventoryCore are there to help the manipulation of this array.

Bubble Sort
Input a Sort Struct, and it will output it sorted. Simple as that. The trick is to set up to Sort Struct Properly.

Swap Slot Data
A member function that is used a lot in the bubble sort. Swaps two indexs in an array.

Add items from JcSort Struct
Adds all the items in a JCSort Struct by order.

Is Item Set
Will tell you if an ItemData is full or not. Basically returns true if the item data is not set to null. Requires the item data to have a Pick up class, a name and a icon.

Scan Index For Space
Checks a index in the array for space. The index is converted to a 2D point in the 2D array, then it will check each point in the 2D array for item data, if the space is emppty Quad is Empty will return true.

Scan Through Inventory for Space
This will gop through the inventory looking for a gap that will fit an item that has the width and height of the input data. It will return true if it found a space and tell you the first index that it found space at.

Grid To Index
Read more about grid to Index here

Index to Grid
Read more about Index to Grid here

Dealing with Item Data
Often we need to grab slot data and item data, or even get item data from an jcInventoryItem .The following helper functions enable us to convert and grab item data with ease.

Get Item Data From class type
Generates item data from an JcInventoryItem, this operation is faster then get item data with attributes as it will try and find an already established itemdata instead of spawning one. If it must spawn one to grab its itemdata it will. The limitation of this call is that you can not inject attributes so it will only grab the standard generic item data from the item.

Get item data from class type with Attributes
Same as above however it will inject whatever provided attributes into the item. Be warned that the injected attributes will override the standard item data attributes. This command will spawn the class, take the data out, then remove it so it should not be used on tick.

Get Item Data
Bread and butter function, this will return the item data of a specific index of the Item slots array. It uses Get Slot Data, then grabs the Item Data From the Slot Data stuct and returns it.

Get Slot Data
This will return the slot data of an index. Note that if you give it an index with a parent index, it will reroute to the parent index and deliver the slot data of the parent index. If you dont wish to do that, you can call the slot data directly with the Get note on the ItemSlots array. Out Index will return what index the command rerouted too.

Find Functions
These are functions to enable you to search through the inventory with ease to see if the player has specific items (think ammunition, or keys)

Find Items In Inventory
This will find all the indexs in the array ItemSlots that have the item data equal to that inputted. It will also return a total amount of that item data the player has.

Find Items In Inventory by Class item
Same as above only will convert the JcInventoryItem to Item data before executing.