Skip to main content

Object Hierarchy And Their Uses

There are 3 class objects which are used for representing the item: UInvnetoryItem, UItemPayload, UInventorySystem. They are all childs of UNestedInventoryArchitectureBaseObject to handle InventoryManager, therefore their replication.

UInventoryItem holds the UItemPayload and UItemPayload holds the UInventorySystem to hold the item's sub inventory.

The Looping Architecture of Holding Sub Inventories Inside Items

The following diagram hopefully makes a bit clearer how the each object get carried. There are no limits to hold containers within containers.

Inventory Item Object

The object that is responsible to represent items without physical representation in the world.

They can behave based on it's Static Data and hold variables inside its Payload to effect gameplay.

Creating childs of this class is not recommended because system will create the base class of the object with its functions, and you have already overridable classes for more customization.

Holded Properties in Inventory Item

PropertyTypeDescription
Item Static DataUItemStaticDataThe static values of the item that will not change during runtime. Responsible for holding the base values of item apperance, behaviour in enviroments etc. Also holds Payload Template inside to create sub inventories and more.
Item PayloadUInventoryItemPayloadThe values which can change at runtime are hold here for any type of gameplay logic.
Item AddresssFItemAddressThe inventory address of the item. Can be invalidated by making a new struct and updating it item is living outside of the inventory.
tip

When you need the spawn actors from items, you can just pass the Inventory Item Object for the created actor. Than spawn the item from the values holded in the Item Static Data, update it's values when the payload changes etc. When these created actors need to be added to inventories, you can just pass the inventory item object without needing to construct a new item.

By the way if you want to construct a new item, the most easy way to do this is calling : CreateInventoryItemFromStaticData from the plug-in's function library.

Inventory Item Payload Object

Responsible for holding the inventory system and variables that can changed at runtime. Can be overriden.

To use the overriden class, select the class in the Payload Template Data Asset. Whenever that template used to create items, selected class will be created for the item.

Inventory System Object

Responsible for handling the inventory system and its operations, such as transferring items, discarding items, and adding items. It also provides the strategy functions for the inventory system to be overridden by the user to customize the behavior of the inventory system.

To use to overriden class go to your Project Settings, under the Plugins section and search for Nested Inventory Architecture. In there you can select that class that will be used whenever a Inventory System gets created. After that whenever a function call is made, your custom code will get run.

Blueprint exposed functions are listed below:

Function NameParametersReturnDescription
Server_SetInventoryconst FInventory& New_InventoryvoidSets the inventory for the inventory system and replicates it. Automatically updates attributes: Slot Occupation, Item Addresses, ParentInventorySystem.
Server_TransferSlotToSlotconst FSlotAddressWithSystem& SourceSlotAddress, const FSlotAddressWithSystem& DestinationSlotAddressvoidTransfers items from one slot to another.
Server_TransferItemOfCountToSlotconst FSlotAddressWithSystem& SourceSlotAddress, const FSlotAddressWithSystem& DestinationSlotAddress, int32 CountvoidTransfers a specific count of items from one slot to another.
Server_DiscardSlotFromInventoryconst FSlotAddressWithSystem& SlotAddressvoidDiscards the slot from the inventory.
Server_AddItemsToInventoryconst TArray<UInventoryItem*>& ItemsToAddvoidAdds items to the inventory.
Server_SetInventorySlotconst FSlotAddressWithSystem& SlotAddress, const TArray<UInventoryItem*>& ItemsToAddvoidSets the slot of the inventory.
Strategy_TransferSlotToSlotFSlotAddressWithSystem SourceSlotAddress, FSlotAddressWithSystem DestinationSlotAddress, bool bUseForTestETransferTypeTransfers items from one slot to another and updates them both. Overridable.
Strategy_TransferItemOfCountToSlotFSlotAddressWithSystem SourceSlotAddress, FSlotAddressWithSystem DestinationSlotAddress, int32 Count, bool bUseForTestETransferTypeTransfers a specific count of items from one slot to another and updates them both. Overridable.
Strategy_DiscardSlotFromInventoryFInventory& InventoryToUpdate, FSlotAddressWithSystem SlotAddressboolDiscards the slot from the inventory and updates the inventory. Overridable.
Strategy_AddItemsToInventoryconst TArray<UInventoryItem*>& ItemsToAddTArray<UInventoryItem*>Adds items to the inventory and updates the inventory. Overridable.
Strategy_SetInventorySlotFInventory& InventoryToUpdate, FSlotAddressWithSystem SlotAddress, const TArray<UInventoryItem*>& ItemsToAddboolSets the slot of the inventory and updates the inventory. Overridable.