Skip to content
Plugin 1.0 · Unreal Engine 5.8Version details

Native extension points ​

Use your own game module for extensions. Replace YOURGAME_API with its API macro and place each reflected class in the header matching its generated include.

Item fragment example ​

This fragment initializes one item's condition. The configuration stays on the shared definition; the value is written to the instance.

cpp
#pragma once

#include "CoreMinimal.h"
#include "Fragments/RicItemFragment.h"
#include "Instances/RicItemInstance.h"
#include "Statics/RicGameplayTags.h"
#include "ItemConditionFragment.generated.h"

UCLASS()
class YOURGAME_API UItemConditionFragment : public URicItemFragment
{
    GENERATED_BODY()

public:
    UPROPERTY(EditDefaultsOnly, Category = "Condition")
    int32 InitialCondition = 100;

    virtual void OnInstanceCreatedNative(
        URicItemInstance* Instance) const override
    {
        if (Instance)
        {
            Instance->SetStatTagStack(
                RicGameplayTags::Item_Stat_Condition,
                FMath::Max(InitialCondition, 0));
        }
    }
};

Add it to the definition's fragment array. Avoid two initializers writing conflicting values to the same statistic unless you deliberately control their order.

Container fragments similarly override OnInstanceCreatedNative(URicContainerBase*) const. Additional fragment configuration should not replace the main implementation fragment.

Native placement filter ​

This filter accepts items carrying the native ammunition category:

cpp
#pragma once

#include "CoreMinimal.h"
#include "Filters/RicFilterBase.h"
#include "Instances/RicItemInstance.h"
#include "Statics/RicGameplayTags.h"
#include "AmmoOnlyFilter.generated.h"

UCLASS()
class YOURGAME_API UAmmoOnlyFilter : public URicFilterBase
{
    GENERATED_BODY()

public:
    virtual bool PassesFilter_Implementation(
        URicItemInstance* Instance,
        const URicContainerBase* Container,
        int32 SlotIndex) const override
    {
        return IsValid(Instance) &&
            Instance->HasMatchingGameplayTag(RicGameplayTags::Item_Ammo);
    }
};

Add its class to a container Filters fragment. Items must carry the Ammo tag through configuration; merely referencing an ammunition definition does not add the tag.

Class-based filters use CDOs. Do not cache the current player, current item, or a previous slot result on the filter.

Native item action ​

This example consumes one item from its inventory. It deliberately rechecks authority and availability in execution.

cpp
#pragma once

#include "CoreMinimal.h"
#include "Actions/RicItemAction.h"
#include "Instances/RicItemInstance.h"
#include "GameFramework/Actor.h"
#include "ConsumeOneAction.generated.h"

UCLASS()
class YOURGAME_API UConsumeOneAction : public URicItemAction
{
    GENERATED_BODY()

public:
    UConsumeOneAction()
    {
        bExecuteOnServer = true;
    }

    virtual FText GetActionName_Native(
        URicItemInstance* Item) override
    {
        return NSLOCTEXT("Inventory", "ConsumeOne", "Consume");
    }

    virtual bool CanShowAction_Native(
        URicItemInstance* Item) const override
    {
        return IsValid(Item) && Item->GetNum() > 0;
    }

    virtual bool ExecuteAction_Native(
        URicItemInstance* Item, int32 Num = 0) override
    {
        AActor* Owner = IsValid(Item) ? Item->GetOwnerActor() : nullptr;
        if (!Owner || !Owner->HasAuthority() ||
            !CanShowAction_Native(Item))
        {
            return false;
        }

        Item->RemoveItem(1);
        return true;
    }
};

Add the class to URicItemFragmentActions::ExecutableActionClasses. Obtain its CDO and invoke Prediction->ExecuteAction(Action, ItemCopy) from your menu.

Your real action must also validate the requesting player's permission and apply the intended gameplay effect. Menu visibility is a presentation check, not authorization. The default action execution returns true without implementing an effect.

Visual resolvers ​

Derive from URicVisualResolver. Use the reflected hooks for text, size, material, initialization, stat changes, and destruction.

The resolver exposes these as Blueprint-native events. Check the declaration of the specific hook before adding a native override; the public header also contains inline implementations. Blueprint subclasses can provide presentation behavior through the exposed events.

Retain material and preview resources in reflected fields. Release item-specific subscriptions/resources in destruction hooks. Use context numbers to separate presentation roles.

Interaction extensions ​

Derive from URicInteractionStrategyBase to change discovery. Override GetInteractionPoints() and initialize through the provided interactor reference.

Interaction fragments provide the OnInstanceCreated hook for point initialization. Availability and execution integration use point state and delegates; the base fragment does not supply an action-execution API.

UI listeners implement IRicInteractionInterface. Their native _Implementation methods are virtual and can be overridden.

Custom containers ​

A new URicContainerBase subclass needs consistent implementations for storage, placement, filters, item enumeration, occupied-slot queries, removal, splitting, events, replication, and persistence.

A main URicContainerFragmentContainerBase derivative selects the new class and initializes its layout. In a native fragment constructor, assign ContainerClass to your container's StaticClass().

Built-in containers batch internal replication changes using a private helper. That helper is not a public module API. Extending concrete built-in behavior through normal operations is the most direct way to retain its lifecycle. If adding a new storage implementation, explicitly implement and verify registration/replication integration.

Swap strategies ​

Override CanSwap() and TrySwap() in URicSwapStrategyBase, then select the class in inventory settings.

Keep checks and execution aligned, preserve GUIDs during transfers, reject cyclic ownership, account for rotation/filters, and define a recovery path if placement fails after an item is displaced. Strategies run as shared CDOs.

Tick handlers ​

URicTickHandler::OnTick is a Blueprint-implementable event. Register a handler Blueprint class through URicInventorySubsystem. It runs on the class default object for top-level containers.

For native periodic gameplay, bind a UFUNCTION() handler to URicGlobalTimeSubsystem::OnTimerTick and traverse the inventory you need. Remove the binding during teardown. This avoids treating the Blueprint-only event as an ordinary virtual C++ override.