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"/>
|
2023-02-23 19:04:16 +01:00
|
|
|
public static int TickingCount => CoroutineHandler.Instance.TickingCount;
|
2020-12-20 17:12:43 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.EventCount"/>
|
2023-02-23 19:04:16 +01:00
|
|
|
public static int EventCount => CoroutineHandler.Instance.EventCount;
|
2020-12-20 17:12:43 +01:00
|
|
|
|
2021-03-16 19:07:28 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.Start(IEnumerable{Wait},string,int)"/>
|
|
|
|
public static ActiveCoroutine Start(IEnumerable<Wait> coroutine, string name = "", int priority = 0) {
|
2023-02-23 19:04:16 +01:00
|
|
|
return CoroutineHandler.Instance.Start(coroutine, name, priority);
|
2020-06-13 02:58:54 +02:00
|
|
|
}
|
|
|
|
|
2021-03-16 19:07:28 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.Start(IEnumerator{Wait},string,int)"/>
|
|
|
|
public static ActiveCoroutine Start(IEnumerator<Wait> coroutine, string name = "", int priority = 0) {
|
2023-02-23 19:04:16 +01:00
|
|
|
return CoroutineHandler.Instance.Start(coroutine, name, priority);
|
2019-06-22 17:24:50 +02:00
|
|
|
}
|
|
|
|
|
2023-02-23 19:08:26 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.InvokeLater(Wait,Action,string,int)"/>
|
2021-03-16 19:07:28 +01:00
|
|
|
public static ActiveCoroutine InvokeLater(Wait wait, Action action, string name = "", int priority = 0) {
|
2023-02-23 19:04:16 +01:00
|
|
|
return CoroutineHandler.Instance.InvokeLater(wait, action, name, priority);
|
2019-11-20 11:30:28 +01:00
|
|
|
}
|
|
|
|
|
2023-02-23 19:08:26 +01:00
|
|
|
/// <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);
|
|
|
|
}
|
|
|
|
|
2021-03-20 02:00:46 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.Tick(double)"/>
|
2019-06-22 17:24:50 +02:00
|
|
|
public static void Tick(double deltaSeconds) {
|
2023-02-23 19:04:16 +01:00
|
|
|
CoroutineHandler.Instance.Tick(deltaSeconds);
|
2019-06-22 17:24:50 +02:00
|
|
|
}
|
2023-02-23 19:08:26 +01:00
|
|
|
|
2021-03-20 02:00:46 +01:00
|
|
|
/// <inheritdoc cref="CoroutineHandlerInstance.Tick(TimeSpan)"/>
|
|
|
|
public static void Tick(TimeSpan delta) {
|
2023-02-23 19:04:16 +01:00
|
|
|
CoroutineHandler.Instance.Tick(delta);
|
2021-03-20 02:00:46 +01:00
|
|
|
}
|
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) {
|
2023-02-23 19:04:16 +01:00
|
|
|
CoroutineHandler.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() {
|
2023-02-23 19:04:16 +01:00
|
|
|
return CoroutineHandler.Instance.GetActiveCoroutines();
|
2019-11-20 11:30:28 +01:00
|
|
|
}
|
|
|
|
|
2019-06-22 17:24:50 +02:00
|
|
|
}
|
|
|
|
}
|