</> Integration
Here we will demonstrate some examples of how to interact with all events of the inventory system.
Add Item
In the InventoryController
script, we have an example of how to add a random item to the inventory using the space key, which essentially calls the following method:
You can add any item to the inventory based on the ItemData
.
Rotate Item
In the InventoryController
script, we have an example using the R key to rotate the item, which essentially calls the following method:
Drop Item
To drop an item from the inventory and use this event, we have a function linked to the drop button in the item panel, which essentially calls the following method:
And the RemoveCurrentItem
method:
With this function, we get the item that is selected with the mouse click, remove the item, and disable its panel so it doesn't stay open even after the item has been removed. But if you just want to remove the item, you can simply call the method:
Split and Stack Item
To stack or split items, we use the following functions in InventoryController
: SplitItem()
and StackItems()
. Currently, we have respective buttons in the item panel to call these functions:
And to stack the item, we use a function to control mouse clicks:
Within this method, we handle the event of placing one item over another:
Within this same function, we analyze where the item is being moved, such as to an equipment slot or another container:
Use Item
To use an item, we also have an event linked to the "Use" button in the item panel:
Which essentially calls the UseItem()
function. This function validates if the item has the stackable attribute. If so, it removes its quantity from the stack; otherwise, it simply deletes the item.
Another note is that in this demo we validate if the item can be used based on its ItemType
:
As you can see, we can consume items of type FoodAndDrink
and Medical
. Below is the method that actually uses the item:
Last updated