From 9db82f3271511854ba42c328aeb115bc7aec0388 Mon Sep 17 00:00:00 2001 From: Syntriax Date: Thu, 16 Apr 2026 11:01:24 +0300 Subject: [PATCH] feat: added ICoroutineManager.IsRunning method --- Engine.Core/Systems/Abstract/ICoroutineManager.cs | 1 + Engine.Core/Systems/CoroutineManager.cs | 2 ++ Engine.Core/Systems/NestedCoroutineManager.cs | 8 ++++++++ 3 files changed, 11 insertions(+) diff --git a/Engine.Core/Systems/Abstract/ICoroutineManager.cs b/Engine.Core/Systems/Abstract/ICoroutineManager.cs index 7d2592a..4ea8f9f 100644 --- a/Engine.Core/Systems/Abstract/ICoroutineManager.cs +++ b/Engine.Core/Systems/Abstract/ICoroutineManager.cs @@ -5,5 +5,6 @@ namespace Engine.Core; public interface ICoroutineManager { IEnumerator StartCoroutine(IEnumerator enumerator); + bool IsRunning(IEnumerator enumerator); void StopCoroutine(IEnumerator enumerator); } diff --git a/Engine.Core/Systems/CoroutineManager.cs b/Engine.Core/Systems/CoroutineManager.cs index 37bff8c..fbda151 100644 --- a/Engine.Core/Systems/CoroutineManager.cs +++ b/Engine.Core/Systems/CoroutineManager.cs @@ -15,6 +15,8 @@ public class CoroutineManager : Behaviour, IUpdate, ICoroutineManager return enumerator; } + public bool IsRunning(IEnumerator enumerator) => enumerators.Contains(enumerator); + public void StopCoroutine(IEnumerator enumerator) { enumerators.Remove(enumerator); diff --git a/Engine.Core/Systems/NestedCoroutineManager.cs b/Engine.Core/Systems/NestedCoroutineManager.cs index 9ee784e..3e15b36 100644 --- a/Engine.Core/Systems/NestedCoroutineManager.cs +++ b/Engine.Core/Systems/NestedCoroutineManager.cs @@ -21,6 +21,14 @@ public class NestedCoroutineManager : Behaviour, IUpdate, ICoroutineManager return enumerator; } + public bool IsRunning(IEnumerator enumerator) + { + for (int i = 0; i < stacks.Count; i++) + if (stacks[i].EntryPoint == enumerator) + return true; + return false; + } + public void StopCoroutine(IEnumerator enumerator) { for (int i = 0; i < stacks.Count; i++)