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/GenerateTileMap.cs | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/Assets/Scripts/GenerateTileMap.cs b/Assets/Scripts/GenerateTileMap.cs
index 8870c8e..d2ea3a2 100644
--- a/Assets/Scripts/GenerateTileMap.cs
+++ b/Assets/Scripts/GenerateTileMap.cs
@@ -28,6 +28,8 @@
private const int CACHE_CLEAR_DISTANCE = 8; // Distance in chunks before clearing cache (should be > LOAD_DISTANCE)
private Vector2Int lastCacheClearPosition; // Track position where cache was last cleared
+ [NonSerialized]
+ public List<Vector3Int> destroyedTiles = new List<Vector3Int>();
private Dictionary<Vector2Int, bool> loadedChunks = new Dictionary<Vector2Int, bool>();
private Dictionary<Vector2Int, TileBase[]> chunkCache = new Dictionary<Vector2Int, TileBase[]>();
private Transform playerTransform; // Reference to player/camera
@@ -62,16 +64,16 @@
//Debug.Log($"Current Chunk: {currentChunk}");
if (currentChunk != lastLoadedChunk)
{
- StartCoroutine(UpdateLoadedChunks(currentChunk, gameManager.destroyedTiles));
+ StartCoroutine(UpdateLoadedChunks(currentChunk, destroyedTiles));
lastLoadedChunk = currentChunk;
// Check if we need to clear the cache
ClearDistantChunks(currentChunk);
}
}
- public Dictionary<Vector2Int, TileBase[]> GetSaveData()
+ public (int seed, Dictionary<Vector2Int, TileBase[]> chunkCache, List<Vector3Int> destroyedTiles) GetSaveValues()
{
- return chunkCache;
+ return (seed.Value, chunkCache, destroyedTiles);
}
public void LoadChunkDataFromSave(List<SerializedChunkData> serializedChunks)
{
@@ -268,7 +270,7 @@
// tilemap.SetTile(tilePos, cachedTiles[i]);
// }
//}
- BatchSetTiles(chunk, cachedTiles, gameManager.destroyedTiles);
+ BatchSetTiles(chunk, cachedTiles, destroyedTiles);
}
yield return null;
}
--
Gitblit v1.10.0