46 lines
1.6 KiB
C#
46 lines
1.6 KiB
C#
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 targetModeStr, string extraArg = "")
|
|
{
|
|
if (!Enum.TryParse<FixSceneMode>(targetModeStr, out var targetMode))
|
|
{
|
|
Debug.Log($"[Yarn] Unknown FixSceneMode: {targetModeStr}");
|
|
yield break;
|
|
}
|
|
|
|
yield return FixSystemCenter.Instance.TransitionTo(targetMode, extraArg);
|
|
}
|
|
|
|
[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] Unknown repair system type: {systemTypeName}");
|
|
yield break;
|
|
}
|
|
|
|
RepairSystemManager.Instance.SwitchSystem(systemType);
|
|
|
|
yield return new WaitForSeconds(RepairSystemManager.Instance.GetComponent<RepairSystemManager>()
|
|
?.GetType().GetField("switchDuration", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)
|
|
?.GetValue(RepairSystemManager.Instance) is float duration ? duration : 0.5f);
|
|
}
|
|
}
|
|
}
|