From dc5206fcedce17dd1ba7bbb8565a894db8784116 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 23 Feb 2023 19:08:26 +0100 Subject: [PATCH] allow invoking later with an event directly --- Coroutine/CoroutineHandler.cs | 8 +++++++- Coroutine/CoroutineHandlerInstance.cs | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Coroutine/CoroutineHandler.cs b/Coroutine/CoroutineHandler.cs index 2575d2a..6254186 100644 --- a/Coroutine/CoroutineHandler.cs +++ b/Coroutine/CoroutineHandler.cs @@ -25,15 +25,21 @@ namespace Coroutine { return CoroutineHandler.Instance.Start(coroutine, name, priority); } - /// + /// public static ActiveCoroutine InvokeLater(Wait wait, Action action, string name = "", int priority = 0) { return CoroutineHandler.Instance.InvokeLater(wait, action, name, priority); } + /// + public static ActiveCoroutine InvokeLater(Event evt, Action action, string name = "", int priority = 0) { + return CoroutineHandler.Instance.InvokeLater(evt, action, name, priority); + } + /// public static void Tick(double deltaSeconds) { CoroutineHandler.Instance.Tick(deltaSeconds); } + /// public static void Tick(TimeSpan delta) { CoroutineHandler.Instance.Tick(delta); diff --git a/Coroutine/CoroutineHandlerInstance.cs b/Coroutine/CoroutineHandlerInstance.cs index 4046b1d..8e47189 100644 --- a/Coroutine/CoroutineHandlerInstance.cs +++ b/Coroutine/CoroutineHandlerInstance.cs @@ -78,6 +78,19 @@ namespace Coroutine { return this.Start(CoroutineHandlerInstance.InvokeLaterImpl(wait, action), name, priority); } + /// + /// Causes the given action to be invoked after the given . + /// This is equivalent to a coroutine that waits for the given wait and then executes the given . + /// + /// The event to wait for + /// The action to execute after waiting + /// The that the underlying coroutine should have. Defaults to an empty string. + /// The that the underlying coroutine should have. The higher the priority, the earlier it is advanced compared to other coroutines that advance around the same time. Defaults to 0. + /// An active coroutine object representing this coroutine + public ActiveCoroutine InvokeLater(Event evt, Action action, string name = "", int priority = 0) { + return this.InvokeLater(new Wait(evt), action, name, priority); + } + /// /// Ticks this coroutine handler, causing all time-based s to be ticked. ///