From 48965decbba06bb4071479ae7f428ee3a89907ce Mon Sep 17 00:00:00 2001 From: ninemine <1371605831@qq.com> Date: Tue, 2 Dec 2025 16:54:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DActionStepCoroutineWrapper?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E9=94=99=E8=AF=AF=E8=B0=83=E7=94=A8=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Convention/[Runtime]/Config.cs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Convention/[Runtime]/Config.cs b/Convention/[Runtime]/Config.cs index 88bdbeb..94b6f1f 100644 --- a/Convention/[Runtime]/Config.cs +++ b/Convention/[Runtime]/Config.cs @@ -1319,28 +1319,30 @@ namespace Convention public class ActionStepCoroutineWrapper { - private class YieldInstructionWrapper + private struct YieldInstructionWrapper { public YieldInstruction UnityYieldInstruction; public CustomYieldInstruction CustomYieldInstruction; - public YieldInstructionWrapper() - { - - } - - public YieldInstructionWrapper(YieldInstruction unityYieldInstruction) + public YieldInstructionWrapper(YieldInstruction unityYieldInstruction, CustomYieldInstruction customYieldInstruction) { this.UnityYieldInstruction = unityYieldInstruction; + this.CustomYieldInstruction = customYieldInstruction; } - public YieldInstructionWrapper(CustomYieldInstruction customYieldInstruction) + public static YieldInstructionWrapper Make(YieldInstruction unityYieldInstruction) { - this.CustomYieldInstruction = customYieldInstruction; + return new(unityYieldInstruction, null); + } + + public static YieldInstructionWrapper Make(CustomYieldInstruction customYieldInstruction) + { + return new(null, customYieldInstruction); } } private List> steps = new(); + public ActionStepCoroutineWrapper Update(Action action) { steps.Add(new(new(), action)); @@ -1348,33 +1350,33 @@ namespace Convention } public ActionStepCoroutineWrapper Wait(float time, Action action) { - steps.Add(new(new(new WaitForSeconds(time)), action)); + steps.Add(new(YieldInstructionWrapper.Make(new WaitForSeconds(time)), action)); return this; } public ActionStepCoroutineWrapper FixedUpdate(Action action) { - steps.Add(new(new (new WaitForFixedUpdate()), action)); + steps.Add(new(YieldInstructionWrapper.Make(new WaitForFixedUpdate()), action)); return this; } public ActionStepCoroutineWrapper Next(Action action) { - steps.Add(new(new(new WaitForEndOfFrame()), action)); + steps.Add(new(YieldInstructionWrapper.Make(new WaitForEndOfFrame()), action)); return this; } public ActionStepCoroutineWrapper Until(Func pr, Action action) { - steps.Add(new(new(new WaitUntil(pr)), action)); + steps.Add(new(YieldInstructionWrapper.Make(new WaitUntil(pr)), action)); return this; } private static IEnumerator Execute(List> steps) { foreach (var (waiting, action) in steps) { - action(); if (waiting.UnityYieldInstruction != null) yield return waiting.UnityYieldInstruction; else yield return waiting.CustomYieldInstruction; + action(); } } ~ActionStepCoroutineWrapper()