using System; using System.Collections; using UnityEngine; using Yarn.Unity; namespace AibisDream.FixSystem { public static class FixSystemYarnCommand { [YarnCommand("switch_fix_system_to")] public static IEnumerator SwitchFixSystemTo(string targetStateStr, string extraArg = "") { // 字符串转枚举 if (!Enum.TryParse(targetStateStr, out var targetState)) { Debug.Log($"{targetStateStr}不在FixState枚举中"); yield break; } yield return FixSystemCenter.StateMachine.SwitchState(targetState, extraArg); } [YarnCommand("play_clinic_cut")] public static IEnumerator PlayClinicCut() { yield return FixSystemCenter.PlayClinicCut(); } #region 维修系统管理器命令 /// /// 切换到指定的维修系统(按类型名称) /// 用法: <> /// [YarnCommand("repair_switch_system")] public static IEnumerator RepairSwitchSystem(string systemTypeName) { Type systemType = systemTypeName switch { "BodyModuleSystem" => typeof(BodyModuleSystem), "BlockPuzzleSystem" => typeof(BlockPuzzleSystem), _ => null }; if (systemType == null) { Debug.LogError($"[Yarn] 未知的系统类型: {systemTypeName}"); yield break; } RepairSystemManager.Instance.SwitchSystem(systemType); // 等待切换动画 yield return new WaitForSeconds(RepairSystemManager.Instance.GetComponent() ?.GetType().GetField("switchDuration", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance) ?.GetValue(RepairSystemManager.Instance) is float duration ? duration : 0.5f); } #endregion } }