Inventory System

Introduction
This documentation elucidates the utilization of the Inventory System Component and Item Collections, empowering designers to craft sophisticated inventory systems with greater finesse.
The essence of inventory is: a component that contains various item collections, storing item stacks in different forms.

Inventory System Component
The Inventory System Component stands as one of the pivotal elements within GIS, serving as the foundation for numerous other features. By attaching a single Inventory System Component to an Actor and pairing it with the appropriate type of Item Collection based on your game design, you can achieve a myriad of inventory configurations.

- CollectionDefinitions: Specifies the types of Item Collections this inventory can encompass, with each collection uniquely identified by a GameplayTag. This tag can also signify the purpose of the collection, allowing multiple collections of the same type to be configured on the Inventory System Component, distinguished by distinct tags.
- Collections: Upon initialization of the inventory system, Item Collection instances are generated, enabling you to observe intricate details of the items within the collection during runtime.
- DefaultLoadouts:You can add default items and their amount for different collection identified by colelction tags.
- CollectionRestrictionSets: For complex scenarios, you can impose various restriction sets on a collection. These restrictions are evaluated before an item is added to or removed from the collection, determining whether the action is permissible.
- IgnoredCollections: Item collection matches these tag will be excluded from item search.
Reference Use Cases
By integrating this component into any Actor, it can serve diverse purposes depending on its configuration:
- Character Inventory: Stores all items belonging to a player.
- Enemy Inventory: Holds items owned by enemies, potential drops, or currently equipped equipments.
- Shop Inventory: Contains all items available in a store.
- Chest Inventory: Allows for random item placement in chests based on game rules, ripe for player scavenging.
- Warehouse Inventory: Functions as a repository for player items or as a resource pool in camp management games.
Common gameplay mechanics such as purchasing items through a shop, picking up items from the ground, or acquiring relics from a defeated enemy can be understood as interactions of item data between distinct Inventory Components.
When you have a need to manage a set of data, the Inventory System Component is an ideal solution.
Item Collections
Collections represent groupings of items, with the items stored within an internal ItemStackContainer(implemented via FastArraySerializer). Each ItemStack is a structure comprising an item instance and its amount. By default, unique items always have an amount of 1, while non-unique items maintain an amount of 1 or greater.
Collection Definitions
Each collection definition is a data asset, which you can defines static data for your collection instance. Upon initialization of the inventory system, the corresponding item collection instance will be crated.
GIS offers three distinct types of collections, each organizing and managing items in subtly different ways:
CollectionDefinition | CollectionInstance |
ItemCollectionDefinition | ItemCollection |
MultiStackItemCollectionDefinition | MultiStackItemCollection |
SlotItemCollectionDefinition | SlotItemCollection |
For more details of these collection types, refer to the respective Item Collection documentation.
Custom Item Collections
While the three default collection types provided by GIS cater to most needs, should you require a specialized solution or find the default implementations unsatisfactory, you can create entirely new Item Collections. The process is as follows:
其步骤如下:
- Create a new subclass of
GIS_ItemCollectionDefinition
and defines all necessary configuration fields for the new collection type. - Create a new subclass of
GIS_ItemCollection
, overriding or extending the original logic. - Override
GetCollectionInstanceClass
in the new ItemCollectionDefinition to return the newly created ItemCollection type.
This will make the new collection type available as a configuration option within the Inventory System Component.
Collection Restrictions
For complex usages, you can apply various restriction to different collections, introducing nuanced rules. These restrictions are evaluated prior to item operations to determine if an item can be added to or removed from a collection.
For instance, a simple restriction set might dictate that the Equipped collection can only contain unique items, while the QuickBar collection has a maximum capacity of 3.
The diagram below illustrates a restriction case for a normal item collection, stipulating that each item stack within the collection may hold a maximum of 99 items. Furthermore, it mandates that only items bearing specific ItemTags are eligible to be included in this collection.

Built-in Restrictions
- ItemRestriction_TagRequirements: Only items matches specific tag query can be added to the designated collection.
- ItemRestriction_StacksNumLimit: Limits the capacity of a specified collection (i.e., the number of item stacks it can hold).
- ItemRestriction_StackSizeLimit: Restricts the maximum amount of an item within a specified collection (e.g., how many apples can it hold at most?).
- ItemRestriction_UniqueOnly: Restricts a specified collection to store only unique items.
Custom Restrictions
Each entry within a restriction set is a customizable blueprint. You can inherit from GIS_ItemRestriction via Blueprint or C++ to implement novel restriction rules.

Designing Your Inventory Layout
As a designer, your initial step is to delineate the Item Collections necessary in your game as containers for items.
Common in-game actions, such as organizing a player’s backpack or equipping weapons, are fundamentally interactions of item data between different collections within a single Inventory Component.
Below is a typical case:
CollectionTag | Purpose |
---|---|
Main | Often serves as the default inventory collection, storing all items of an Actor. The “InventoryMenu” in the paired project typically track data from this collection. |
Equipped | Items in this collection are considered “equipped,” often paired with ItemSlotCollection. The “EquipmentMenu” in the paired project usually track data from this collection. |
Hidden | Items invisible to players can be stored in this collection. |
Inventory System API
All APIs are meticulously categorized for ease of reference, with each accompanied by detailed annotations. Their core functionality revolves around the creation, deletion, modification, and querying of items.
These APIs are fundamentally encapsulations of the Item Collection APIs. While the underlying internal logic may vary across different collection types, their APIs remain strikingly similar. The APIs exposed by the Inventory System Component are sufficient to meet most requirements, with more specific collection APIs elaborated upon in the dedicated Item Collection documentation.

Regarding Item Information
You may have noticed that although collections internally store each item stack as an ItemStack, the APIs for adding, removing, modifying, and querying operate via ItemInfo.
This is because ItemInfo not only encapsulates information about the item instance and its quantity but also includes references to ItemStackId and ItemCollection. This allows you to specify the source of an item before adding it.
For instance, with MultiStackItemCollection, if you transfer 100 apples from ActorA’s inventory to ActorB’s inventory, but ActorB’s inventory is limited to a maximum of 99 apples, you can use the ItemCollection reference in ItemInfo to return the surplus apple to ActorA’s inventory.
Similarly, through StackId, you can add items to a specific item stack.