refactor(fix-system): FixPanel 与 Cable 迁移为显式快照

This commit is contained in:
2026-06-24 22:43:39 +08:00
parent 57b03aeb08
commit d780ff59ee
4 changed files with 193 additions and 25 deletions
@@ -1,5 +1,6 @@
using AibisDream.Framework;
using AibisDream.Kit;
using AibisDream.SaveSystem;
using UnityEngine;
using System.Collections;
using DG.Tweening;
@@ -125,6 +126,67 @@ namespace AibisDream.FixSystem
#endregion
#region Capture / Restore
public FixPanelSnapshotDto CapturePanelSnapshot()
{
var cablePanel = GetRepairPanel<CablePanel>();
var dto = new FixPanelSnapshotDto
{
isSystemOn = isSystemOn,
currentRepairSystemType = repairSystemManager?.GetCurrentSystemType()?.Name,
isCableRetracted = cablePanel != null && cablePanel.isCableRetracted
};
if (cablePanel != null && cablePanel.TryGetPluggedModuleName(out var moduleName))
{
dto.pluggedModuleName = moduleName;
}
if (dto.isCableRetracted && !string.IsNullOrEmpty(dto.pluggedModuleName))
{
Debug.LogWarning("[FixPanelSystem] Capture: isCableRetracted 与 pluggedModuleName 冲突,忽略 pluggedModuleName。");
dto.pluggedModuleName = null;
}
return dto;
}
public void ApplyPanelSnapshot(FixPanelSnapshotDto dto)
{
if (dto == null) return;
ApplySystemOnImmediate(dto.isSystemOn);
if (repairSystemManager != null)
{
repairSystemManager.RestoreSystemType(dto.currentRepairSystemType);
}
GetRepairPanel<CablePanel>()?.ApplyCableSnapshot(dto.isCableRetracted, dto.pluggedModuleName);
}
/// <summary>读档终态:跳过 StartAllSystems 动画,直接写面板壳层状态。</summary>
public void ApplySystemOnImmediate(bool isOn)
{
isSystemOn = isOn;
if (panelLight != null)
{
panelLight.Initialize(isOn);
}
var cablePanel = GetRepairPanel<CablePanel>();
cablePanel?.InitLight(isOn);
if (screenPanel != null)
{
screenPanel.gameObject.SetActive(isOn);
}
}
#endregion
#region
[Header("默认画布")]
[SerializeField] private Canvas canvas;