refactor: extracted interface from TweenManager

This commit is contained in:
Syntriax 2025-05-03 22:23:28 +03:00
parent 48ae24af47
commit a93e55619c
2 changed files with 11 additions and 4 deletions

View File

@ -0,0 +1,9 @@
namespace Syntriax.Engine.Systems.Tween;
public interface ITweenManager
{
ITween StartTween(float duration, TweenSetCallback? setCallback = null);
void CancelTween(ITween tween);
delegate void TweenSetCallback(float t);
}

View File

@ -5,13 +5,13 @@ using Syntriax.Engine.Core;
namespace Syntriax.Engine.Systems.Tween; namespace Syntriax.Engine.Systems.Tween;
public class TweenManager : UniverseObject public class TweenManager : UniverseObject, ITweenManager
{ {
private CoroutineManager coroutineManager = null!; private CoroutineManager coroutineManager = null!;
private readonly Dictionary<ITween, IEnumerator> runningCoroutines = []; private readonly Dictionary<ITween, IEnumerator> runningCoroutines = [];
public ITween StartTween(float duration, TweenSetCallback? setCallback = null) public ITween StartTween(float duration, ITweenManager.TweenSetCallback? setCallback = null)
{ {
Tween tween = new(duration); Tween tween = new(duration);
tween.OnUpdated += tween => setCallback?.InvokeSafe(tween.Value); tween.OnUpdated += tween => setCallback?.InvokeSafe(tween.Value);
@ -61,6 +61,4 @@ public class TweenManager : UniverseObject
{ {
coroutineManager = null!; coroutineManager = null!;
} }
public delegate void TweenSetCallback(float t);
} }