/// <summary> /// Loads state of the inventory. /// </summary> /// <param name="character"></param> public void LoadInventory(Character character) { ItemContainerSaveData savedInventorySlots = ItemSaveIO.LoadItems(InventoryFileName); if (savedInventorySlots != null) { character.InventoryManager.Inventory.Clear(); for (int i = 0; i < savedInventorySlots.SavedSlots.Length; i++) { ItemSlot itemSlot = character.InventoryManager.Inventory.ItemSlots[i]; ItemSlotSaveData savedSlot = savedInventorySlots.SavedSlots[i]; itemSlot.Item = (savedSlot != null) ? itemConfig.GetItemClone(savedSlot.ItemId) : null; if (itemSlot.Item != null) { character.InventoryManager.Inventory.AddItem(itemSlot.Item); } } } }