Inventory Components¶
Overview¶
The Inventory system is built around UMIPBaseInventoryManagerComponent (IMC), which holds a replicated list of item entries, slot counts, and sorting state. UMIPPlayerServerIMC extends it for the player (equip/unequip, consume, move, swap). UMIPStoragesManagerComponent and storage IMCs (UMIPStorageIMC, UMIPDynamicStorageIMC, UMIPNPCStorageIMC) manage multiple inventories (storages) and moving items between them. UMIPItemSelectionComponent handles UI-driven item selection (e.g. repair one, enhance).
Key traits:
- Server-authoritative: Add/remove/move/swap are server RPCs or server-only; replication keeps clients in sync.
- Save: Items and slot state are persisted via the save system; saveable component integration for load order.
- Slots: Max size, unlocked size, temp unlocked, used slots; expansion and slot checks for add/move.
All paths below are relative to Plugins/ModularInventoryPlus/Source/ModularInventoryPlus/.
Key Classes & Files¶
| Class | File |
|---|---|
UMIPBaseInventoryManagerComponent |
Public/Inventory/MIPBaseInventoryManagerComponent.h |
UMIPPlayerServerIMC |
Public/Inventory/PlayerInventory/MIPPlayerServerIMC.h |
UMIPStoragesManagerComponent |
Public/Inventory/Storage/MIPStoragesManagerComponent.h |
UMIPStorageIMC |
Public/Inventory/Storage/MIPStorageIMC.h |
UMIPDynamicStorageIMC |
Public/Inventory/Storage/MIPDynamicStorageIMC.h |
UMIPNPCStorageIMC |
Public/Inventory/Storage/MIPNPCStorageIMC.h |
UMIPItemSelectionComponent |
Public/Inventory/ItemSelection/MIPItemSelectionComponent.h |
UMIPAdvancedChatItemLinkerComponent |
(inventory-related; see plugin Public/Inventory) |
Component Hierarchy¶
UMIPBasePlayerControllerComponent
└── UMIPBaseInventoryManagerComponent (base IMC; implements IAbilitySystemInterface)
└── UMIPPlayerServerIMC (player inventory: equip, consume, swap, move)
└── UMIPStorageIMC (generic storage)
├── UMIPDynamicStorageIMC (tag-based dynamic storage)
└── UMIPNPCStorageIMC (NPC-bound storage)
UMIPBaseSaveableComponent
└── UMIPStoragesManagerComponent (holds StorageIMCs + DynamicStorageIMCs, active storage, move-to-storage)
UMIPClientPlayerControllerComponent
└── UMIPItemSelectionComponent (StartItemSelection / StopItemSelection, hover callbacks)
UMIPBaseInventoryManagerComponent¶
- Replication:
FMIPItemList UnsortedInventoryList,UsedItemSlots,UniqueInventoryTag(ReplicatedUsing). - Slots:
MaxInventorySize,UnlockedInventorySize,TempUnlockedSlotsSize,SlotsPerRow. Helpers:GetTotalUnlockedSlotsCount(),IsAtMaxSlots(),CheckHasEnoughSlots,CheckHasEnoughSlotForItem,GetRequiredItemSlots,IsSlotIndexUnlocked. Unlock is driven byUMIPControllerCommonSaveableObjectsComponent(permanent) or temp internal. - Items:
GetItemEntriesConst(),GetItemEntryAtIndexConst,HasEnoughItem,HasItemTag,GetItemIndexByTag,GetItemIndexByUniqueId,GetItemCountByTag,GetFreeItemIndex,IsIndexFree. Add:AddItemByTag/AddItemByTagNoNotification. Remove:RemoveItem_ServerOnly,RemoveItemByTag_ServerOnly,RemoveItemByUniqueId_ServerOnly. Load:LoadItem,OnItemFullyLoaded. Create:CreateTempItemEntry,CreateTempItemEntryWithAssetId,CreateTempItemEntryWithDynamicPieces. - Move:
MoveItemToAnotherInventory(InTargetIMC, ...),CheckThisInventoryCanMoveForItem. - Swap:
SwapItemIndexes,ServerSwapIndexes. - Currency:
RemoveCurrency,HasEnoughCurrency(delegate toUMIPCurrencyComponent). - Sorting:
SortedItemsMapping,GetItemEntryAtSortedIndex,GetRealItemIndex,GetSortedItemIndex,bAutoArrange,OnAutoArrangeStateChanged,SortAndBroadcast,ClientItemEntriesSortedDelegate. - Delegates:
ItemEntryChangedDelegate,ClientItemEntriesSortedDelegate,OnItemSlotsCountChangedDelegate. - Save:
GetSaveID(),MarkPieceDirty,MarkItemEntryDirty/K2_MarkItemEntryAsDirty. Listens toOnAllLoadingCompletedand replication change.
UMIPPlayerServerIMC¶
- Delegates:
ItemEntryRemovedDelegate,OnItemEquippedDelegate,OnItemUnequippedDelegate,OnEquipmentMeshShowOrHideDelegate,ClientEquipmentEntryRemovedDelegate,ClientEquipmentEntryAddedDelegate,NotifyAddItemResultDelegate,ClientOnConsumeItemDelegate,ServerOnConsumedItemDelegate,ClientOnFailedToConsumeItem,EquipUnEquipSoundDelegate. - Struct:
FMIPRemovedItemInfo(RemovedItemType, ItemPrimaryTag, ItemUniqueId, ItemIndex). Equip/unequip and mesh show/hide use the existing structs in the codebase. - Behavior: Extends base IMC with server RPCs for equip, unequip, consume, and client/server delegate flow for UI and gameplay.
UMIPStoragesManagerComponent¶
- Attachment: Owned by actor that has saveable + storage responsibility (e.g. player).
- Storage lists:
StorageIMCs,DynamicStorageIMCs(by tag).FindStorageIMCByTag,GetCurrentActiveStorageIMC,GetCurrentActiveStorageTag,GetDynamicStorageIMCByTag,GetCurrentActiveDynamicStorageIMC.AddStorageIMC,AddUniqueStorageIMC. - Move:
StartMoveItemToStorage(FromIndex, ToIndex, Amount),OnMoveItemFromStorage(callback with value + additional data). - Repurchase:
GetRepurchaseStorageLastSoldSequence(Tag),IncrementRepurchaseStorageLastSoldSequence(Tag);RepurchaseStorageTagAndSequenceMap(SaveGame). - Delegates:
StorageItemEntryChangedDelegate,OnDynamicInventoryItemEntryChangedDelegate.OnItemEntryChanged,OnDynamicInventoryItemEntryChangedforward to these. - Config:
EndStorageInteractionTags– when interaction ends, active storage can be cleared or updated as needed.
UMIPStorageIMC / UMIPDynamicStorageIMC / UMIPNPCStorageIMC¶
- UMIPStorageIMC: Base storage IMC;
TryMoveItemToStorageOnServer,ServerMoveItemToInventory,ClientInitializeStorage. - UMIPDynamicStorageIMC:
InitializeDynamicStorage(UniqueInventoryTag),RemoveFirstSoldItem; overridesOnItemEntryChanged,OnRep_UniqueInventoryTag; registers with manager inAddDynamicStorageIMCToManager. - UMIPNPCStorageIMC: Spawnable storage component for NPCs; overrides
BeginPlayandOnItemEntryChanged.
UMIPItemSelectionComponent¶
- Attachment: Client PlayerController (
UMIPClientPlayerControllerComponent). - API:
StartItemSelection(InItemSelectionTag),StopItemSelection(),OnItemHovered(InItemEntry),OnItemUnhovered(InItemEntry)(and selection result flow). UsesUMIPSettings→ItemSelectionMapping(tag →TSubclassOf<UMIPBaseItemSelectionChecker>). Cursor changes viaUMIPCursorComponent::ChangeCursorWithName(disabled cursor during selection; default on stop). - Delegates:
FOnItemSelection,FOnItemSelectionSelected(item selection tag + result struct). Used for repair-one, enhance, etc. via custom checkers (e.g.UMIPRepairOneItemSelectionChecker).
Integration¶
- Save/Load: Inventory entries and slot counts are saved/loaded via server load component and saveable objects; IMC listens for
OnAllLoadingCompleted. - Currency: Fee checks and removal go through
UMIPCurrencyComponentreferenced on the base IMC. - Equipment: See UMIPEquipmentGE and equipment components; equip/unequip delegates on
UMIPPlayerServerIMC. - Action progress / level features: Level-based features (e.g. enhance, reforge) use
UMIPBasePlayerLevelBasedFeatureComponentand may trigger inventory operations.