allow invoking later with an event directly

This commit is contained in:
Ell 2023-02-23 19:08:26 +01:00
parent 201369f167
commit dc5206fced
2 changed files with 20 additions and 1 deletions

View file

@ -25,15 +25,21 @@ namespace Coroutine {
return CoroutineHandler.Instance.Start(coroutine, name, priority);
}
/// <inheritdoc cref="CoroutineHandlerInstance.InvokeLater"/>
/// <inheritdoc cref="CoroutineHandlerInstance.InvokeLater(Wait,Action,string,int)"/>
public static ActiveCoroutine InvokeLater(Wait wait, Action action, string name = "", int priority = 0) {
return CoroutineHandler.Instance.InvokeLater(wait, action, name, priority);
}
/// <inheritdoc cref="CoroutineHandlerInstance.InvokeLater(Event,Action,string,int)"/>
public static ActiveCoroutine InvokeLater(Event evt, Action action, string name = "", int priority = 0) {
return CoroutineHandler.Instance.InvokeLater(evt, action, name, priority);
}
/// <inheritdoc cref="CoroutineHandlerInstance.Tick(double)"/>
public static void Tick(double deltaSeconds) {
CoroutineHandler.Instance.Tick(deltaSeconds);
}
/// <inheritdoc cref="CoroutineHandlerInstance.Tick(TimeSpan)"/>
public static void Tick(TimeSpan delta) {
CoroutineHandler.Instance.Tick(delta);

View file

@ -78,6 +78,19 @@ namespace Coroutine {
return this.Start(CoroutineHandlerInstance.InvokeLaterImpl(wait, action), name, priority);
}
/// <summary>
/// Causes the given action to be invoked after the given <see cref="Event"/>.
/// This is equivalent to a coroutine that waits for the given wait and then executes the given <see cref="Action"/>.
/// </summary>
/// <param name="evt">The event to wait for</param>
/// <param name="action">The action to execute after waiting</param>
/// <param name="name">The <see cref="ActiveCoroutine.Name"/> that the underlying coroutine should have. Defaults to an empty string.</param>
/// <param name="priority">The <see cref="ActiveCoroutine.Priority"/> 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.</param>
/// <returns>An active coroutine object representing this coroutine</returns>
public ActiveCoroutine InvokeLater(Event evt, Action action, string name = "", int priority = 0) {
return this.InvokeLater(new Wait(evt), action, name, priority);
}
/// <summary>
/// Ticks this coroutine handler, causing all time-based <see cref="Wait"/>s to be ticked.
/// </summary>