|
|
|
|
|
|
public class SaveSystem : ScriptableObject |
|
|
|
{ |
|
|
|
[SerializeField] private LoadEventChannelSO _loadLocation = default; |
|
|
|
[SerializeField] private Inventory _playerInventory; |
|
|
|
|
|
|
|
public string saveFilename = "save.chop"; |
|
|
|
public Save saveData = new Save(); |
|
|
|
|
|
|
{ |
|
|
|
saveData._locationId = locationSo.SerializableGuid; |
|
|
|
} |
|
|
|
|
|
|
|
SaveGame(); |
|
|
|
} |
|
|
|
|
|
|
|
public void LoadGame() |
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
saveData._itemStacks.Clear(); |
|
|
|
foreach (var itemStack in _playerInventory.Items) |
|
|
|
{ |
|
|
|
saveData._itemStacks.Add(new SerializedItemStack(itemStack.Item.SerializableGuid, itemStack.Amount)); |
|
|
|
} |
|
|
|
|
|
|
|
if (FileManager.WriteToFile(saveFilename, saveData.ToJson())) |
|
|
|
{ |
|
|
|
Debug.Log("Save successful"); |
|
|
|