public void SaveInventory() { var data = new ContainerSaveData(slots); for (int i = 0; i < data.savedSlots.Length; i++) { if (items[i] != null) { if (items[i].item == null) { data.savedSlots[i] = null; } else { data.savedSlots[i] = new ItemSaveData(items[i].item, items[i].amount); } } else { data.savedSlots[i] = null; } } ItemSaveIO.SaveItems(data, gameObject.name); }
public void LoadInventory() { ContainerSaveData data = ItemSaveIO.LoadItems(gameObject.name); if (data == null) { return; } ItemData[] idata = new ItemData[data.savedSlots.Length]; for (int i = 0; i < data.savedSlots.Length; i++) { if (data.savedSlots[i] != null) { Item item = itemDatabase.GetItemCopy(data.savedSlots[i].itemID); idata[i] = new ItemData(item, data.savedSlots[i].amount); } } items = idata; }
public static void SaveItems(TInv.ContainerSaveData items, string path) { FileReadWrite.WriteToBinaryFile(baseSavePath + "/" + path + ".dat", items); }