Appearance
Inventory operations
Choose the correct entry point
Use container and manager methods in authoritative gameplay setup, item rewards, and server-side inventory logic. Use URicClientPredictedInventoryComponent for local player interaction. It performs local work and submits corresponding server requests.
The examples below assume pointers have been checked and gameplay permission has been validated.
RPC forwarding
URicItemOperationsRPCsComponent implements reliable server RPCs for inventory operations, actions, statistics, ammunition transfers, and quick-slot assignments. For predicted movement, stacking, and splitting on a remote client, the prediction component first performs the local operation. After success, it forwards the corresponding request with source references or GUIDs so the server can apply it to authoritative state.
URicClientPredictedInventoryComponent::GetRPCComponent() returns nullptr on authority. Standalone and listen-server host inventory operations therefore work directly with source objects through this facade. Quick-slot prediction can still invoke the gateway's Server functions on authority, where they execute locally without network forwarding.
The supplied UI already uses this flow. See Inventory RPCs for the component's role.
Add from a definition
For one container:
cpp
int32 Added = 0;
Container->AddItemDefinition(Definition, 30, Added);
const int32 Remaining = 30 - Added;For manager-wide placement:
cpp
#include "Statics/RicGameplayTags.h"
FGameplayTagContainer Roots;
Roots.AddTag(RicGameplayTags::Container_Type_Main);
int32 Added = 0;
Manager->AddItemFromDefinition(
Definition, 30, Added, Roots, true);Here true enables nested placement under selected roots. Use an empty tag container to select all eligible roots.
A successful addition can be partial. Treat OutItemsAdded as the quantity accepted. Do not charge for or remove a requested quantity until your gameplay has accounted for the remainder.
Add with statistics and stack policy
cpp
#include "Structures/RicStructures.h"
#include "Statics/RicGameplayTags.h"
FRicAddItemParams Params;
Params.StackPolicy = ERicEStackPolicy::ForceNewSlots;
FRicStatStack Condition;
Condition.Tag = RicGameplayTags::Item_Stat_Condition;
Condition.Num = 75;
Params.GameplayTags.Add(Condition);
FRicAddResult Result;
Container->AddItemWithParams(Definition, 3, Params, Result);For the jigsaw implementation:
Auto: fill compatible existing stacks, then create new instances.ForceNewSlots: avoid existing stacks; create new stacks up to their maximum.NoStack: avoid existing stacks and create individual instances of quantity 1.
FRicAddResult::AddedItemCount is the accepted quantity. AddedItemIds identifies newly placed instances. StackedItemIds identifies existing stacks that received quantities.
Manager AddItemFromDefinitionWithParams() aggregates results across its selected containers. The single-item container has one destination instance; do not assume it can satisfy a request requiring multiple independent instances.
Transfer an existing item
AddItemRef(Item, Added, Rotation) attempts automatic placement of an existing instance. AddItemRefToSlot(Item, Slot, Rotation) attempts a specific position.
cpp
#include "Statics/RicStatics.h"
const FGuid ItemID = Item->GetID();
const bool Moved =
Destination->AddItemRefToSlot(Item, 8, ERicRotation::D90);
// Resolve the current object after a successful ownership transfer.
URicItemInstance* Current = Destination->FindItemByID(ItemID);A transfer across managers can replace the instance while retaining its GUID. Use the resolved reference for subsequent subscriptions and gameplay.
Capacity checks such as CanAddItemRef, CanAddItemToSlot, and CanFitInEmptySlots help show available placement. Execution still needs to handle changing state.
Predicted movement and drop
cpp
const bool PredictedMove = Prediction->MoveItemRotated(
ItemCopy, ERicRotation::D90, DestinationCopy, 8);Use GetDropAction() for hover feedback, then ProcessDrop() when the user releases the item:
cpp
bool Handled = false;
const ERicDropAction Action = Prediction->ProcessDrop(
DestinationCopy, ItemCopy, ERicRotation::D0, SlotIndex, Handled);Possible actions are None, Add, Swap, Stack, Nest, and Return. The returned action describes the route; inspect the output result as well. Server replication can later correct the local outcome.
ForceMoveItemRotated() resolves by GUID for requests that must not depend on a stale client instance reference. It still uses the destination's placement rules.
Stack and split
Prediction->StackItems(Target, Incoming, Added) merges compatible stacks and reports quantity moved. The authoritative utility is URicStatics::StackItems(Target, Incoming, Added).
Ordinary stack compatibility is based on matching definitions and available stack capacity. It does not compare every custom statistic, condition value, or nested inventory. Use a maximum stack of 1 for items whose individual state must remain separate, or extend your game's stacking policy explicitly.
Dropping compatible ammunition onto a magazine can also transfer rounds into its ammo count. This uses the magazine's configured ammo definition and capacity rather than increasing its item quantity.
Prediction->SplitItem(Item, Num) searches the current container, siblings owned by the same item, then that inventory in depth order. SplitItemInOwningContainer() restricts placement to the current container.
Splitting requires a valid quantity and a placement for the resulting item. A split creates a new GUID. Stacking can consume the incoming instance; resolve references again after the operation.
Remove and discard
cpp
Container->RemoveItem(Item, 2); // Consume two.
Container->RemoveItem(Item); // Remove the entire stack.-1 means the entire stack. Clear() removes a container's contents.
For player prediction:
cpp
Prediction->RemoveItem(ItemCopy, 2, true);The final parameter requests the manager's OnItemDiscarded notification. This event is the integration point for your game to create a world pickup or other discard effect. Removing an item does not itself supply your world actor implementation.
Nested placement
Dropping onto a containing item can select Nest. The container checks for a valid child destination and prevents ownership cycles. Use ProcessDrop() or Prediction->NestItem() so player actions use the corresponding server route.
Swap strategies
Configure URicInventorySettings::SwapStrategy. Both built-in strategies use CanSwap() to inspect a candidate and TrySwap() to execute.
Buffer strategy (URicSwapStrategySwapBoofer, header RicSwapStrategySwapBuffer.h) moves the displaced item into the swap buffer and places the incoming item at the target. The buffer must be tagged Ric.Container.Type.Swap, accept the displaced item, and be empty unless the dragged source is its current item.
Provide this container in the owning manager's definitions; the manager does not automatically create it. A single-item buffer is useful because it accepts one complete instance independently of grid footprint, subject to filters.
After a handled buffer swap, continue dragging or placing the buffered item. true indicates the operation was handled and state changed; if source placement unexpectedly fails after buffering, the displaced item can remain buffered for manual recovery.
Relocate strategy (URicSwapStrategyRelocate) plans a placement for the displaced item near the target or in the vacated source position. It uses the buffer as temporary storage. Unexpected execution failures can leave the displaced item there.
Prediction's GUID-based swap request includes the expected target ID. The server checks the current target before exchanging items, avoiding an exchange with a different item after a stale prediction.
Load and unload magazines
Configure the magazine item with:
URicItemFragmentMagazineData::AmmoItemDefinition.Ric.Item.Stat.MaxAmmoCountfor capacity.Ric.Item.Stat.AmmoCountfor current rounds.
Use Prediction->LoadAmmo(MagazineCopy) and UnloadAmmo(MagazineCopy). Loading consumes matching ammunition quantities; unloading restores quantities to compatible stacks or available container space. A transfer can be partial.
These methods handle inventory ammunition. Your weapon code supplies firing, animation, reload timing, and attachment/equipment behavior. The internal ammunition helper lives in the module's private directory; use the public predicted component and RPC gateway for integration.