Save & Load

Persistence and disk saving

The UMP_InventoryComponent includes built-in serialization support for data persistence across sessions.

Configuration

  • bAutoSaveLoad: A boolean property on the component. When set to true, the component will automatically attempt to load its state during initialization and save its state when modified.

Data Serialization

Inventory data is serialized into a custom SaveGame class.

  • The FMP_InventoryItem struct determines what data is preserved.
  • By default, the struct saves the ItemID, Quantity, and SlotIndex.
  • If custom item properties (such as durability or attachments) are required, they must be included within the FMP_InventoryItem struct to ensure they are serialized during the save process.

Save and Load Events

The UMP_InventoryManager provides event hooks for save operations:

  • OnInventorySync: A delegate broadcasted to the client when a save or load operation completes. It passes a boolean indicating whether it was a save operation (true) or load operation (false), alongside the InventoryID.
  • Client_OnInventorySync: The underlying RPC that triggers OnInventorySync and fires a notification (e.g., [InventoryID] Loaded).