diff --git a/Assets/Scripts/AssetRefs/ConstRef.cs b/Assets/Scripts/AssetRefs/ConstRef.cs index fbca620f5..2d9b8f360 100644 --- a/Assets/Scripts/AssetRefs/ConstRef.cs +++ b/Assets/Scripts/AssetRefs/ConstRef.cs @@ -23,6 +23,10 @@ namespace AibisDream.Utility public static readonly string SaveFilePath = Path.Combine(Application.persistentDataPath, "AllOurBrokenParts", "saves"); + /// 测试阶段自动存档历史目录;每次自动存档独立子文件夹,不覆盖正式槽位。 + public static readonly string TestAutoSaveArchivePath = + Path.Combine(Application.persistentDataPath, "AllOurBrokenParts", "testsavs"); + /// P2 槽位相关常量。 public const int SaveSlotCount = 8; public const int SaveThumbnailWidth = 640; diff --git a/Assets/Scripts/FixSystem/PunchType/PunchTapeManager.cs b/Assets/Scripts/FixSystem/PunchType/PunchTapeManager.cs index 5327f1d54..c4f1ad069 100644 --- a/Assets/Scripts/FixSystem/PunchType/PunchTapeManager.cs +++ b/Assets/Scripts/FixSystem/PunchType/PunchTapeManager.cs @@ -1,15 +1,14 @@ using System; -using System.Collections; using System.Collections.Generic; +using System.Linq; using AibisDream.Kit; -using UnityEngine; -using AibisDream.Framework; using AibisDream.SaveSystem; +using UnityEngine; namespace AibisDream.FixSystem { /// - /// 打孔带系统入口:收藏数据、存档注册、Yarn 命令、弹窗与收藏夹面板代理。 + /// 打孔带系统入口:收藏数据、Yarn 命令、弹窗与收藏夹面板代理。 /// public class PunchTapeManager : Singleton { @@ -20,48 +19,54 @@ namespace AibisDream.FixSystem [SerializeField] private PunchTapePrinter punchTapePrinter; public PunchTapePrinter PunchTapePrinter => punchTapePrinter; - private readonly PunchTapeCollectionData _collectionData = new(); + private readonly List _favorites = new(); private GameObject currentPunchTapeGO; /// 收藏列表变更时通知 等订阅方。 public event Action OnCollectionChanged; - public override void OnSingletonInit() - { - DeepRepairDataRegistry.RegisterData(_collectionData); - _collectionData.LoadEvent += OnCollectionDataLoaded; - } - - public override void OnSingletonDestroy() - { - _collectionData.LoadEvent -= OnCollectionDataLoaded; - } - - private void OnCollectionDataLoaded(PunchTapeCollectionData data) - { - OnCollectionChanged?.Invoke(); - } - public IReadOnlyList GetFavorites() { - return _collectionData.punchTapeFavorites; + return _favorites; + } + + public PunchTapeSnapshotDto CapturePunchTapeSnapshot() + { + return new PunchTapeSnapshotDto + { + favorites = _favorites.Select(t => new PunchTape(t.Category, t.ClueName, t.MemoryIndex) + { + used = t.used + }).ToList() + }; + } + + public void ApplyPunchTapeSnapshot(PunchTapeSnapshotDto dto) + { + _favorites.Clear(); + if (dto?.favorites != null) + { + _favorites.AddRange(dto.favorites); + } + + OnCollectionChanged?.Invoke(); } public void AddPunchTape(PunchTape punchTape) { if (punchTape == null) return; - if (_collectionData.punchTapeFavorites.Contains(punchTape)) + if (_favorites.Contains(punchTape)) return; - _collectionData.punchTapeFavorites.Add(punchTape); + _favorites.Add(punchTape); OnCollectionChanged?.Invoke(); } public void RemovePunchTape(PunchTape punchTape) { if (punchTape == null) return; - if (!_collectionData.punchTapeFavorites.Remove(punchTape)) + if (!_favorites.Remove(punchTape)) return; OnCollectionChanged?.Invoke(); @@ -130,20 +135,4 @@ namespace AibisDream.FixSystem currentPunchTapeGO = null; } } - - /// - /// 打孔带收藏列表的存档载体;由 注册到 。 - /// - public class PunchTapeCollectionData : IData - { - public List punchTapeFavorites = new(); - - public event Action LoadEvent; - - public IEnumerator Load() - { - LoadEvent?.Invoke(this); - yield break; - } - } -} \ No newline at end of file +} diff --git a/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs b/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs index a0a93d46e..e237a0921 100644 --- a/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs +++ b/Assets/Scripts/MiniGame/Peipei/Eye/EyeSystem.cs @@ -8,8 +8,8 @@ using System.Linq; using UnityEngine.UI; using AibisDream.FixSystem; using AibisDream.Framework; -using AibisDream.SaveSystem; using AibisDream.Kit; +using AibisDream.SaveSystem; using UnityEngine.ResourceManagement.AsyncOperations; using Sequence = DG.Tweening.Sequence; @@ -28,10 +28,19 @@ namespace AibisDream public GameObject eyeView; public ViewCameraManager cameraManager; private IEyeStateEffect eyeStateEffect; - private EyeData _eyeData = new(); + private EyeColorState _currentState = EyeColorState.CannotImagineColor; /// 获取当前 Eye 颜色阶段。 - public EyeData.EyeColorState GetCurrentColorState() => _eyeData.currentState; + public EyeColorState GetCurrentColorState() => _currentState; + + public enum EyeColorState + { + CanImagineColor, + CannotImagineColor, + EyeDisorder, + CanSeeColor, + HaveChip + } private Tween hsvShiftTween; private MouseFollowAndZoom mouseFollowAndZoom; @@ -71,20 +80,29 @@ namespace AibisDream public void Init() { FixSystemCenter.SystemDic.Register(this); - DeepRepairDataRegistry.RegisterData(_eyeData); - // 添加加载逻辑 - _eyeData.LoadEvent += LoadData; - - // 确保 ViewCamera 默认不激活 + if (cameraManager != null) { cameraManager.gameObject.SetActive(false); } } - private void LoadData(EyeData eyedata) + public EyeSnapshotDto CaptureEyeSnapshot() { - SetEyeColorState(eyedata.currentState); + return new EyeSnapshotDto { eyeColorState = _currentState.ToString() }; + } + + public void ApplyEyeSnapshot(EyeSnapshotDto dto) + { + if (dto == null || string.IsNullOrEmpty(dto.eyeColorState)) + { + return; + } + + if (Enum.TryParse(dto.eyeColorState, true, out EyeColorState state)) + { + SetEyeColorState(state); + } } public void OnEnter() @@ -141,7 +159,7 @@ namespace AibisDream private void Start() { - SetEyeColorState(_eyeData.currentState); + SetEyeColorState(_currentState); mouseFollowAndZoom = FindObjectOfType(); } @@ -265,7 +283,7 @@ namespace AibisDream public void SetEyeColorStateForYarn(string state) { // Try to parse the string as an EyeColorState - if (!Enum.TryParse(state, true, out EyeData.EyeColorState eyeState)) + if (!Enum.TryParse(state, true, out EyeColorState eyeState)) { throw new ArgumentException("Invalid eye state: " + state, nameof(state)); } @@ -274,24 +292,24 @@ namespace AibisDream SetEyeColorState(eyeState); } - private void SetEyeColorState(EyeData.EyeColorState state) + private void SetEyeColorState(EyeColorState state) { - _eyeData.currentState = state; + _currentState = state; switch (state) { - case EyeData.EyeColorState.CanImagineColor: + case EyeColorState.CanImagineColor: eyeStateEffect = new CanImagineColorEffect(); break; - case EyeData.EyeColorState.CannotImagineColor: + case EyeColorState.CannotImagineColor: eyeStateEffect = new CannotImagineColorEffect(); break; - case EyeData.EyeColorState.EyeDisorder: + case EyeColorState.EyeDisorder: eyeStateEffect = new EyeDisorderEffect(); break; - case EyeData.EyeColorState.CanSeeColor: + case EyeColorState.CanSeeColor: eyeStateEffect = new CanSeeColorEffect(); break; - case EyeData.EyeColorState.HaveChip: + case EyeColorState.HaveChip: eyeStateEffect = new HaveChip(); break; default: @@ -471,7 +489,7 @@ namespace AibisDream [YarnCommand("EyeGetColor")] public void GetColor() { - SetEyeColorState(EyeData.EyeColorState.CanImagineColor); + SetEyeColorState(EyeColorState.CanImagineColor); // 对目标列表中的每个目标执行 ColorBack 方法 foreach (EyeTarget target in targets) { @@ -481,25 +499,4 @@ namespace AibisDream // 切换到 CanImagineColorEffect 状态 } } - - public class EyeData : IData - { - public enum EyeColorState - { - CanImagineColor, - CannotImagineColor, - EyeDisorder, - CanSeeColor, - HaveChip - } - - public EyeColorState currentState = EyeColorState.CannotImagineColor; - public event Action LoadEvent; - - public IEnumerator Load() - { - LoadEvent?.Invoke(this); - yield break; - } - } } \ No newline at end of file