using Engine.Core; namespace Engine.Systems.Tween; public static class TweenVector4DExtensions { private static readonly BoxedPool boxedVector4DPool = new(2); public static ITween TweenVector4D(this Vector4D initialVector4D, ITweenManager tweenManager, float duration, Vector4D targetVector4D, System.Action setMethod) { Boxed boxedInitial = boxedVector4DPool.Get(initialVector4D); Boxed 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; } }