From 6b1abe7afb9350a7890f6b893f59f72a3988aaab Mon Sep 17 00:00:00 2001
From: miepzerino <o.skotnik@gmail.com>
Date: Mon, 07 Apr 2025 16:15:36 +0000
Subject: [PATCH] #50 added saveDataManager

---
 Assets/Scripts/Managers/GameManager.cs |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs
index cf3a5ab..a759205 100644
--- a/Assets/Scripts/Managers/GameManager.cs
+++ b/Assets/Scripts/Managers/GameManager.cs
@@ -22,8 +22,6 @@
     public Tilemap tilemap;
     [NonSerialized]
     public GenerateTileMap generateTileMap;
-    [NonSerialized]
-    public List<Vector3Int> destroyedTiles = new List<Vector3Int>();
     public GameObject pickups;
     public Tilemap fogTilemap;
     public FogOfWar fogOfWar;
@@ -47,7 +45,7 @@
             LoadMapState();
         }
         Debug.Log("waiting for async map loading");
-        StartCoroutine(generateTileMap.GenerateTiles(LoadTileMapsFinished, destroyedTiles));
+        StartCoroutine(generateTileMap.GenerateTiles(LoadTileMapsFinished, generateTileMap.destroyedTiles));
     }
 
     private void InitializeBackgroundTiles()
@@ -71,7 +69,7 @@
 
     private void LoadMapState()
     {
-        SaveDataMap mapState = SaveSystem.LoadMapState();
+        SaveDataMap mapState = GetComponent<SaveSystemManager>().GetMapStateFromSave();
         if (mapState != null)
         {
             //fogOfWar.LoadFromSaveData(mapState.fogOfWarData);
@@ -82,7 +80,7 @@
                 // TODO rework load map (it's fucky wucky currently as I had to make an extra class for it to jsonify the tiles correctly, as unity does not like lists of arrays or 2d arrays)
                 foreach (DestroyedTile tile in mapState.destroyedTiles)
                 {
-                    destroyedTiles.Add(tile.tileCoord.ConvertToVector3Int());
+                    generateTileMap.destroyedTiles.Add(tile.tileCoord.ConvertToVector3Int());
                 }                //destroyedTiles.AddRange(mapState.destroyedTiles.Select(tile => { return tile.tileCoord; }).ToList().ConvertToVector3Int());
             }
             // Load chunk cache
@@ -206,7 +204,7 @@
                 }
                 // Update tilemap
                 tilemap.SetTile(cellCoord, null);
-                destroyedTiles.Add(cellCoord);
+                generateTileMap.destroyedTiles.Add(cellCoord);
                 generateTileMap.UpdateChunkCache(cellCoord, cellWorldPosition);
                 CharacterEvents.characterDrillingToPosition.Invoke(cellWorldPosition, drillDirection);
             }

--
Gitblit v1.9.3