2019-06-22 17:24:50 +02:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
|
|
namespace Coroutine {
|
2020-06-13 03:12:26 +02:00
|
|
|
/// <summary>
|
|
|
|
/// This class can be used for static coroutine handling of any kind.
|
|
|
|
/// Note that it uses an underlying <see cref="CoroutineHandlerInstance"/> object for management.
|
|
|
|
/// </summary>
|
2019-06-22 17:24:50 +02:00
|
|
|
public static class CoroutineHandler {
|
|
|
|
|
2020-06-13 03:02:11 +02:00
|
|
|
private static readonly CoroutineHandlerInstance Instance = new CoroutineHandlerInstance();
|
2019-06-22 17:24:50 +02:00
|
|
|
|
2020-12-20 17:12:43 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.TickingCount"/>
|
|
|
|
public static int TickingCount => Instance.TickingCount;
|
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.EventCount"/>
|
|
|
|
public static int EventCount => Instance.EventCount;
|
|
|
|
|
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.Start(IEnumerable{Wait},string)"/>
|
|
|
|
public static ActiveCoroutine Start(IEnumerable<Wait> coroutine, string name = "") {
|
|
|
|
return Instance.Start(coroutine, name);
|
2020-06-13 02:58:54 +02:00
|
|
|
}
|
|
|
|
|
2020-12-20 17:12:43 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.Start(IEnumerator{Wait},string)"/>
|
|
|
|
public static ActiveCoroutine Start(IEnumerator<Wait> coroutine, string name = "") {
|
|
|
|
return Instance.Start(coroutine, name);
|
2019-06-22 17:24:50 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 03:12:26 +02:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.InvokeLater"/>
|
2020-12-20 17:12:43 +01:00
|
|
|
public static ActiveCoroutine InvokeLater(Wait wait, Action action) {
|
|
|
|
return Instance.InvokeLater(wait, action);
|
2019-11-20 11:30:28 +01:00
|
|
|
}
|
|
|
|
|
2020-06-13 03:12:26 +02:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.Tick"/>
|
2019-06-22 17:24:50 +02:00
|
|
|
public static void Tick(double deltaSeconds) {
|
2020-06-13 03:02:11 +02:00
|
|
|
Instance.Tick(deltaSeconds);
|
2019-06-22 17:24:50 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 03:12:26 +02:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.RaiseEvent"/>
|
2019-06-22 17:24:50 +02:00
|
|
|
public static void RaiseEvent(Event evt) {
|
2020-06-13 03:02:11 +02:00
|
|
|
Instance.RaiseEvent(evt);
|
2019-06-22 17:24:50 +02:00
|
|
|
}
|
|
|
|
|
2020-06-13 03:12:26 +02:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.GetActiveCoroutines"/>
|
2020-03-24 23:47:27 +01:00
|
|
|
public static IEnumerable<ActiveCoroutine> GetActiveCoroutines() {
|
2020-06-13 03:02:11 +02:00
|
|
|
return Instance.GetActiveCoroutines();
|
2019-11-20 11:30:28 +01:00
|
|
|
}
|
|
|
|
|
2019-06-22 17:24:50 +02:00
|
|
|
}
|
|
|
|
}
|