存档完善和修复

This commit is contained in:
2026-05-20 15:26:51 +08:00
parent ec633d9b79
commit 8ae2de5bcb
10 changed files with 106 additions and 41 deletions

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using BaseGames.Core;
using BaseGames.Core.Events;
@@ -53,18 +52,14 @@ namespace BaseGames.World.Map
public void OnSave(SaveData data)
{
data.Map.ExploredRooms ??= new List<string>();
data.Map.ExploredRooms.Clear();
data.Map.ExploredRooms.AddRange(_exploredRooms);
data.Map.MappedRooms ??= new List<string>();
data.Map.MappedRooms.Clear();
data.Map.MappedRooms.AddRange(_mappedRooms);
data.Map.ExploredRooms = new HashSet<string>(_exploredRooms);
data.Map.MappedRooms = new HashSet<string>(_mappedRooms);
}
public void OnLoad(SaveData data)
{
_exploredRooms = new HashSet<string>(data.Map.ExploredRooms ?? new System.Collections.Generic.List<string>());
_mappedRooms = new HashSet<string>(data.Map.MappedRooms ?? new System.Collections.Generic.List<string>());
_exploredRooms = data.Map.ExploredRooms != null ? new HashSet<string>(data.Map.ExploredRooms) : new HashSet<string>();
_mappedRooms = data.Map.MappedRooms != null ? new HashSet<string>(data.Map.MappedRooms) : new HashSet<string>();
}
// ── 事件驱动房间发现 ──────────────────────────────────────────────────