| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using UnityEngine; |
| | | using UnityEngine.Tilemaps; |
| | | |
| | | #region player data |
| | | [Serializable] |
| | |
| | | public int seed; |
| | | public List<DestroyedTile> destroyedTiles; |
| | | public FogOfWarData fogOfWarData; |
| | | public SaveDataMap(List<Vector3Int> destroyedTiles, int seed, FogOfWarData fogOfWarData) |
| | | public List<SerializedChunkData> chunkData; // New field |
| | | public SaveDataMap(List<Vector3Int> destroyedTiles, int seed, FogOfWarData fogOfWarData, Dictionary<Vector2Int, TileBase[]> chunkCache) |
| | | { |
| | | this.seed = seed; |
| | | this.destroyedTiles = new List<DestroyedTile>(); |
| | |
| | | { |
| | | this.destroyedTiles.Add(new DestroyedTile(item)); |
| | | } |
| | | // Convert chunk cache to serializable format |
| | | this.chunkData = chunkCache.Select(kvp => new SerializedChunkData(kvp.Key, kvp.Value)).ToList(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | public List<FogTileData> discoveredTiles = new List<FogTileData>(); |
| | | } |
| | | [System.Serializable] |
| | | public class SerializedChunkData |
| | | { |
| | | public Vector2Int position; |
| | | public string[] tileNames; // Store tile names instead of TileBase references |
| | | |
| | | public SerializedChunkData(Vector2Int pos, TileBase[] tiles) |
| | | { |
| | | position = pos; |
| | | tileNames = tiles.Select(t => t != null ? t.name : "null").ToArray(); |
| | | } |
| | | } |
| | | #endregion |