refactor: extracted interface from TweenManager
This commit is contained in:
parent
48ae24af47
commit
a93e55619c
9
Engine.Systems/Tween/ITweenManager.cs
Normal file
9
Engine.Systems/Tween/ITweenManager.cs
Normal 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);
|
||||||
|
}
|
@ -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);
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user