feat(fix-system): 支持 Fix 系统任务面板与身体模块状态读档恢复
This commit is contained in:
@@ -72,7 +72,7 @@ namespace AibisDream.FixSystem
|
||||
RepairSystemManager.Register(this);
|
||||
}
|
||||
|
||||
/// <summary>捕获插线模块持久状态(分组 + UF + Chip)。</summary>
|
||||
/// <summary>捕获插线模块持久状态(分组 + UF + Chip + 高亮/报警)。</summary>
|
||||
public BodyModuleSnapshotDto CaptureBodyModuleSnapshot()
|
||||
{
|
||||
var dto = new BodyModuleSnapshotDto
|
||||
@@ -86,6 +86,13 @@ namespace AibisDream.FixSystem
|
||||
var chipModule = FindBodyModuleByName("Color")?.GetComponent<ChipModule>();
|
||||
chipModule?.CaptureState(dto);
|
||||
|
||||
foreach (var module in EnumerateAllBodyModules())
|
||||
{
|
||||
var name = module.data.moduleName;
|
||||
if (module.IsHighlighted) dto.highlightedModules.Add(name);
|
||||
if (module.IsAlarmed) dto.alarmedModules.Add(name);
|
||||
}
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
@@ -105,6 +112,31 @@ namespace AibisDream.FixSystem
|
||||
|
||||
var chipModule = FindBodyModuleByName("Color")?.GetComponent<ChipModule>();
|
||||
chipModule?.ApplyState(dto);
|
||||
|
||||
var highlighted = new HashSet<string>(dto.highlightedModules ?? Enumerable.Empty<string>());
|
||||
var alarmed = new HashSet<string>(dto.alarmedModules ?? Enumerable.Empty<string>());
|
||||
|
||||
foreach (var module in EnumerateAllBodyModules())
|
||||
{
|
||||
var name = module.data.moduleName;
|
||||
module.Highlight(highlighted.Contains(name));
|
||||
module.Alarm(alarmed.Contains(name));
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<BodyModule> EnumerateAllBodyModules()
|
||||
{
|
||||
if (_bodyModuleGroup != null)
|
||||
{
|
||||
foreach (var module in _bodyModuleGroup.GetComponentsInChildren<BodyModule>(true))
|
||||
yield return module;
|
||||
}
|
||||
|
||||
if (_headModuleGroup != null)
|
||||
{
|
||||
foreach (var module in _headModuleGroup.GetComponentsInChildren<BodyModule>(true))
|
||||
yield return module;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user