A slot inventory with stacks, item fragments, and an optional shape grid for Unreal Engine.
A slot inventory with stacks, item fragments, and an optional shape grid for Unreal Engine.
NsBackpack is a slot inventory for gameplay programmers. An actor gets a backpack component with a fixed number of slots. Each slot holds an item, a quantity, and optional item data. An item is a data asset with a name, an icon, a mesh, a stack size, and fragments that your game makes. The optional NsBackpackGrid module puts the slots in a grid, where an item covers the cells of its shape.
NsBackpack has no UI, no selected slot, no item use, no crafting, and no save system. It has no server RPCs, so your game sends the change requests to the server. NsBackpack depends on no other plugin.
CanAccept and CanStack in C++ or Blueprint.Grid Shape fragment cover a box or any set of cells, and turn by quarter turns.Unreal Engine 5.7+
NsBackpack folder into the Plugins folder of your project."NsBackpack" to the dependencies of your game module in Build.cs. Add "NsBackpackGrid" too for a grid.NsBackpackItemDefinition.UNsBackpackComponent to your character.Add Item with the item and a quantity.On Changed to update your UI.In C++:
#include "NsBackpackComponent.h"
// In the constructor of the character
Backpack = CreateDefaultSubobject<UNsBackpackComponent>(TEXT("Backpack"));
// On the server. The return value is the quantity that did not fit.
const int32 Left = Backpack->AddItem(BoltItem, 15);
| Module | Content |
|---|---|
NsBackpack |
The slot component, the item definition, the fragment base class, and the slot types |
NsBackpackGrid |
The grid component and the Grid Shape fragment. It depends only on NsBackpack |
UNsBackpackComponent – The slots. AddItem, RemoveItem, RemoveFromSlot, MoveSlot, SetSlot, CountItem, FindItem, FindEmptySlot, and OnChanged.UNsBackpackItemDefinition – The data asset of one kind of item. FindFragment returns its first fragment of a class.UNsBackpackItemFragment – The abstract base class of game data on an item.FNsBackpackSlot – An item, a quantity, and an FInstancedStruct of item data.UNsBackpackGridComponent – A backpack with its slots in a grid. PlaceItem, MoveItem, RotateItem, CanPlace, FindPlacement, and GetCellOwner.UNsBackpackGridShape – The Grid Shape fragment: a box size and the cells inside the box.ResetSlots or ResetGrid call.