From ad79d9ca49274cc660fc2030a071b24314f0f210 Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Sat, 29 Mar 2025 21:33:41 +0000
Subject: [PATCH] added flexalon UI and reworked inventoryUI

---
 Assets/Scripts/SaveSystem.cs |   57 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/Assets/Scripts/SaveSystem.cs b/Assets/Scripts/SaveSystem.cs
index 71ff8ee..bfe2c48 100644
--- a/Assets/Scripts/SaveSystem.cs
+++ b/Assets/Scripts/SaveSystem.cs
@@ -5,14 +5,13 @@
 public static class SaveSystem
 {
     public static bool isGameLoaded = false;
-    public static void SavePlayer(PlayerController player)
+    public static void SavePlayer(SaveDataPlayer player)
     {
         if (player != null)
         {
             string path = System.IO.Path.Combine(Application.persistentDataPath, "player.savefile");
 
-            SaveData saveData = new SaveData(player);
-            string saveDataJSON = JsonUtility.ToJson(saveData);
+            string saveDataJSON = JsonUtility.ToJson(player);
 
             using (FileStream fs = new FileStream(path, FileMode.Create))
             {
@@ -25,13 +24,13 @@
         }
         else
         {
-            Debug.Log("Not saved as no playerController was sent");
+            Debug.Log("Not saved as no playerData was sent");
         }
     }
 
-    public static SaveData LoadPlayer ()
+    public static SaveDataPlayer LoadPlayer()
     {
-        SaveData result;
+        SaveDataPlayer result;
         string path = System.IO.Path.Combine(Application.persistentDataPath, "player.savefile");
         if (File.Exists(path))
         {
@@ -40,7 +39,51 @@
                 using (StreamReader sr = new StreamReader(fs))
                 {
                     string saveData = sr.ReadToEnd();
-                    result = JsonUtility.FromJson<SaveData>(saveData);
+                    result = JsonUtility.FromJson<SaveDataPlayer>(saveData);
+                }
+            }
+        }
+        else
+        {
+            Debug.LogError("Save file not found in: " + path);
+            return null;
+        }
+        return result;
+    }
+    public static void SaveMapState(SaveDataMap mapState)
+    {
+        if (mapState != null)
+        {
+            string path = System.IO.Path.Combine(Application.persistentDataPath, "map.savefile");
+            string saveDataJSON = JsonUtility.ToJson(mapState);
+
+            using (FileStream fs = new FileStream(path, FileMode.Create))
+            {
+                using (StreamWriter sw = new StreamWriter(fs))
+                {
+                    sw.Write(saveDataJSON);
+
+                }
+            }
+        }
+        else
+        {
+            Debug.Log("Not saved as no mapData was sent");
+        }
+    }
+
+    public static SaveDataMap LoadMapState()
+    {
+        SaveDataMap result;
+        string path = System.IO.Path.Combine(Application.persistentDataPath, "map.savefile");
+        if (File.Exists(path))
+        {
+            using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
+            {
+                using (StreamReader sr = new StreamReader(fs))
+                {
+                    string saveData = sr.ReadToEnd();
+                    result = JsonUtility.FromJson<SaveDataMap>(saveData);
                 }
             }
         }

--
Gitblit v1.9.3