Inventory Component

UMP_InventoryComponent reference

The UMP_InventoryComponent is the absolute core of the plugin. It is an Actor Component that acts as the physical container for items. Any Actor in your game that needs to hold items-Players, Chests, Vehicles, Dropped Backpacks, or even NPCs-must have this component attached.

Core Storage: The FastArray System

At the heart of the component is the FMP_InventoryFastArray. Instead of using a standard Unreal Engine TArray (which replicates the entire array every time one item changes), this plugin uses FFastArraySerializer. When an item is added, removed, or updated, only the exact FMP_InventoryItem delta is sent across the network. This ensures massive MMO-scale scalability without choking network bandwidth.

Slot Modes: Strict vs Infinite

The component supports two entirely different inventory paradigms natively, controlled by the Is Strict property (bIsStrict).

1. Strict Mode (Grid/Slot Based)

  • Best For: Games like Resident Evil, Escape from Tarkov, or Minecraft hotbars.
  • How it Works: The inventory has a rigid number of slots (defined by Max Slots). An item lives at a specific index. If you move an item from Slot 0 to Slot 5, it physically remains at Slot 5. Empty slots are represented as empty spaces.
  • Logical vs Physical Indexing: The component maintains an Index Mapping Tracker so the UI always gets the exact correct Slot Index, even if the underlying physical network array shifts.

2. Infinite Mode (List Based)

  • Best For: RPGs like Skyrim, Fallout, or The Witcher.
  • How it Works: The inventory acts as a shifting list. If you have 5 items and drop the item at Index 2, the items at Index 3 and 4 instantly shift up to fill the gap.
  • Performance: The physical FastArray removes the element and shifts seamlessly without breaking replication.

Weight Tracking System

If your game requires encumbrance mechanics, you can enable Enforce Weight Limit.

  • Max Weight Capacity: Defines the maximum allowed weight for this specific component.
  • When a player attempts to add an item, the component calculates the current cumulative weight plus the incoming (Item Weight * Quantity). If it exceeds the maximum, the action is rejected and a notification is sent to the UI.

Locking Mechanics

The component supports a bInventoryLocked state. When true, the entire inventory is frozen. This is crucial for:

  • Active Trading: Locking both players' inventories during a trade confirmation to prevent item duplication or race conditions.
  • Death States: Locking a player's backpack while they are dying.

Key Blueprint Delegates

The component broadcasts several extremely important server-to-client delegates that your UI should listen to:

  • OnInventoryUpdated: Triggered when an item is added, removed, or changed. Returns (FName InventoryID, EInventoryDelta Delta, int32 SlotIndex).
  • OnInventoryResized: Triggered when the maximum slots value changes. Returns (FName InventoryID, int32 NewSize).