Warning texts when water pressure is increasing to dangerous levels and when running out of oxygen, added a method for invoking an arbitrary action after a delay to CoroutineManager

This commit is contained in:
Joonas Rikkonen
2017-11-14 19:10:43 +02:00
parent 157d9dcaba
commit ff926c1da2
6 changed files with 110 additions and 32 deletions
@@ -37,6 +37,26 @@ namespace Barotrauma
return handle;
}
public static void InvokeAfter(Action action, float delay)
{
StartCoroutine(DoInvokeAfter(action, delay));
}
private static IEnumerable<object> DoInvokeAfter(Action action, float delay)
{
if (action == null)
{
yield return CoroutineStatus.Failure;
}
yield return new WaitForSeconds(delay);
action();
yield return CoroutineStatus.Success;
}
public static bool IsCoroutineRunning(string name)
{
return Coroutines.Any(c => c.Name == name);