Container
Manages the container and position where the backing item is stored, and provides the Move and Swap operations, along with other utility functions.
Modifying Requests
Since it implements IItemContextModifierInterface
, this fragment is invoked for every item added to the inventory, to ensure they are placed either in the position that has been originally requested, or the next best one available.
Everything happens automatically, and you don't need to worry about it, but if the item cannot be placed, then it will be marked for a drop and additional information will be available in the logs, under the LogNinjaInventory
category.
Item Placement
If you want to invoke the placement operation yourself for other purposes, you can invoke the appropriate function, SetBestContainerAndPositionForItem
, which will evaluate the best container and position for an item.
If you just want to know what are the best container and position available, without persisting the item, you can also use FindBestContainerForItem
and FindBestPositionForItem
.
There are other useful functions that you may want to explore for other placement queries, such as IsValidPosition
and IsPreferredContainer
.
Move Operation
This fragment provides the Move operation, which can be created via the CreateMovePayload
function. It moves the item to a new container and position.
Swap Operation
This fragment provides the Swap operation, which can be created via the CreateSwapPayload
function. Swaps two items, exchanging their containers and positions.
Additional Containers
An item can add additional containers to the inventory. This is useful for items that can provide their own storage, like boxes, pots and so on.
Containers added via this fragment are registered to the inventory, along with their items. Once the item is removed, the container is removed with it.
Keep in mind that you can also add containers from an active equipment, meaning that containers are only registered when an item is activated. This is more suited represent items like a backpack.