The InventorySlot is used during game play, and contains a direct reference to the InventoryItem that is in the slot. Our saving system, however, cannot serialize that reference, it’s far too complex. (In fact, even if you saved a memory pointer to where the item is located, there is no guarantee that the next run the item would be in the same memory location).
Our saving system needs something a bit simpler, so for this, we’re using the itemID of the Inventory item. CaptureState gets the ItemID, and RestoreState uses the ItemID to load the correct Inventory Item.