25 lines
		
	
	
		
			830 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			830 B
		
	
	
	
		
			C#
		
	
	
	
	
	
using Engine.Core;
 | 
						|
 | 
						|
namespace Engine.Systems.Tween;
 | 
						|
 | 
						|
public static class TweenVector4DExtensions
 | 
						|
{
 | 
						|
    private static readonly BoxedPool<Vector4D> boxedVector4DPool = new(2);
 | 
						|
 | 
						|
    public static ITween TweenVector4D(this Vector4D initialVector4D, ITweenManager tweenManager, float duration, Vector4D targetVector4D, System.Action<Vector4D> setMethod)
 | 
						|
    {
 | 
						|
        Boxed<Vector4D> boxedInitial = boxedVector4DPool.Get(initialVector4D);
 | 
						|
        Boxed<Vector4D> boxedTarget = boxedVector4DPool.Get(targetVector4D);
 | 
						|
 | 
						|
        ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.Lerp(boxedTarget.Value, t)));
 | 
						|
 | 
						|
        tween.OnComplete(() =>
 | 
						|
        {
 | 
						|
            boxedVector4DPool.Return(boxedInitial);
 | 
						|
            boxedVector4DPool.Return(boxedTarget);
 | 
						|
        });
 | 
						|
 | 
						|
        return tween;
 | 
						|
    }
 | 
						|
}
 |