Skip to content
Plugin 1.0 · Unreal Engine 5.8Version details

Items and runtime statistics ​

Definition and instance ​

Include Definitions/RicItemDefinition.h for assets and Instances/RicItemInstance.h for runtime items.

A definition's Fragments array supplies optional capabilities. An instance contains the definition reference, GUID, stack-tag container, ownership, and any nested containers.

Create items through container additions or subsystem construction. Calling NewObject<URicItemInstance> alone does not configure a usable inventory item.

Read item data ​

cpp
#include "Instances/RicItemInstance.h"
#include "Fragments/Item/RicItemFragmentText.h"
#include "Statics/RicGameplayTags.h"

void InspectItem(const URicItemInstance* Item)
{
    if (!IsValid(Item))
    {
        return;
    }

    const FGuid ID = Item->GetID();
    const int32 Count = Item->GetNum();
    const int32 Condition = Item->GetStatTagStackCount(
        RicGameplayTags::Item_Stat_Condition);

    if (const URicItemFragmentText* Text =
            Item->FindFragment<URicItemFragmentText>())
    {
        UE_LOG(LogTemp, Log, TEXT("%s: %d, condition %d, ID %s"),
            *Text->Name.ToString(), Count, Condition, *ID.ToString());
    }
}

Fragment lookup can return null. A text, icon, mesh, or magazine fragment is only available when configured on the definition.

For multiple fragments, use FindFragmentsByClass() and cast individual entries. This also makes the handling of multiple matching fragments explicit.

Stack-tag statistics ​

Items and container managers share the same storage and reading interface. See Gameplay tags and statistics for the full contract, initialization, notifications, and replication behavior.

Runtime tags map FGameplayTag to integer counts. Use:

  • GetStatTagStackCount(Tag): read a value.
  • GetStatTagStackCount(Tag) > 0: test presence.
  • SetStatTagStack(Tag, Count): replace a value.
  • AddStatTagStack(Tag, Count): add positive counts.
  • RemoveStatTagStack(Tag, Count): remove positive counts.

The read methods come from IRicGameplayStackTagAssetInterface. Values are counts: nonpositive values remove the tag rather than storing a negative statistic. Use your own runtime schema for signed or floating-point attributes.

cpp
// In authoritative gameplay code, after validating the item:
Item->SetStatTagStack(RicGameplayTags::Item_Stat_Condition, 75);

For local predicted edits, use SetItemStatTagStack, AddItemStatTagStack, or RemoveItemStatTagStack on URicClientPredictedInventoryComponent.

Stat tags do not automatically implement weight capacity, durability degradation, health effects, prices, or energy consumption. Your gameplay interprets those values.

Stack count and maximum ​

GetNum() reads Ric.Item.Stat.StackCount. GetMaxStack() reads Ric.Item.Stat.MaxStackSize with a minimum of 1. SetNum() clamps to this maximum.

Configure an explicit positive maximum in the stats fragment. A maximum of 1 expresses an unstackable item. Use addition and stacking APIs to enforce placement behavior; a direct SetNum() call should not be treated as a complete validated item-reward operation.

Changing stack count to zero through normal item removal removes the item from inventory. RemoveItem(-1) removes the entire stack.

Shapes and rotation ​

Use one shape provider:

  • URicItemFragmentJigsawItemShape: a filled rectangle.
  • URicItemFragmentJigsawItemShapeCustom: dimensions with an occupied-cell bit mask.

GetShape() returns the item's configured shape. GetItemOccupiedSlots() returns its occupied cells in its current container.

Rotation is stored as Ric.Item.Stat.Rotation. Use ERicRotation::D0, D90, D180, and D270, not degree integers cast into the enum. Check URicStatics::CanRotateItem(); an item rotation fragment overrides project defaults.

Nested inventory ​

An item can contain one or more containers:

  • URicItemFragmentContainer creates one from ContainerDefinition.
  • URicItemFragmentContainerCollection creates the collection's compartments.

Use GetContainers() for immediate children and GetContainersRecursive() for deeper contents. Query child containers by tag when attaching equipment or looking up a magazine socket.

Events and identity ​

OnGameplayTagChanged reports item, tag, old count, and new count. OnOuterContainerChanged reports old and new containers. OnStackStart identifies the items involved in a stack operation.

Bind to the current runtime object. If a transfer or synchronization replaces it, resolve it again by GUID and rebuild subscriptions. Unbind when the consumer is destroyed or changes items.