refactor(fix-system): FixPanel 与 Cable 迁移为显式快照
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user