diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index 629c16b..33060d8 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -1236,7 +1236,7 @@ } /// - /// 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task + /// 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task, SignalAwaiter /// public long StartCoroutine(IEnumerator able) { diff --git a/DungeonShooting_Godot/src/framework/coroutine/CoroutineData.cs b/DungeonShooting_Godot/src/framework/coroutine/CoroutineData.cs index 15b3cbc..03c678c 100644 --- a/DungeonShooting_Godot/src/framework/coroutine/CoroutineData.cs +++ b/DungeonShooting_Godot/src/framework/coroutine/CoroutineData.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; +using Godot; /// /// 协程数据 @@ -16,6 +17,7 @@ WaitForSeconds, WaitForFixedProcess, WaitForTask, + WaitForSignalAwaiter, } /// @@ -36,6 +38,7 @@ public WaitForSeconds WaitForSeconds; public WaitForFixedProcess WaitForFixedProcess; public Task WaitTask; + public SignalAwaiter WaitSignalAwaiter; public CoroutineData(IEnumerator enumerator) { @@ -60,4 +63,10 @@ WaitState = WaitTypeEnum.WaitForTask; WaitTask = task; } + + public void WaitFor(SignalAwaiter task) + { + WaitState = WaitTypeEnum.WaitForSignalAwaiter; + WaitSignalAwaiter = task; + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs b/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs index 9190e08..1e1c6b7 100644 --- a/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs +++ b/DungeonShooting_Godot/src/framework/coroutine/ProxyCoroutineHandler.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using System.Threading.Tasks; +using Godot; /// /// 协程代理类 @@ -55,6 +56,18 @@ item.WaitTask = null; } } + else if (item.WaitState == CoroutineData.WaitTypeEnum.WaitForSignalAwaiter) //等待信号 + { + if (!item.WaitSignalAwaiter.IsCompleted) + { + canNext = false; + } + else + { + item.WaitState = CoroutineData.WaitTypeEnum.None; + item.WaitSignalAwaiter = null; + } + } if (canNext) { @@ -93,6 +106,10 @@ { item.WaitFor(task); } + else if (next is SignalAwaiter awaiter) //等待信号 + { + item.WaitFor(awaiter); + } } else { @@ -110,7 +127,7 @@ } /// - /// 代理协程, 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task + /// 代理协程, 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task, SignalAwaiter /// public static long ProxyStartCoroutine(ref List coroutineList, IEnumerator able) { diff --git a/DungeonShooting_Godot/src/framework/ui/UiBase.cs b/DungeonShooting_Godot/src/framework/ui/UiBase.cs index 5e2377c..e454424 100644 --- a/DungeonShooting_Godot/src/framework/ui/UiBase.cs +++ b/DungeonShooting_Godot/src/framework/ui/UiBase.cs @@ -142,7 +142,7 @@ } /// - /// 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task + /// 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task, SignalAwaiter /// public long StartCoroutine(IEnumerator able) { diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index 29675f5..2c7388e 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -153,7 +153,7 @@ } /// - /// 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task + /// 开启一个协程, 返回协程 id, 协程是在普通帧执行的, 支持: 协程嵌套, WaitForSeconds, WaitForFixedProcess, Task, SignalAwaiter /// public long StartCoroutine(IEnumerator able) {