using Engine.Core; namespace Engine.Systems.Tween; public static class TweenLine2DEquationExtensions { private static readonly BoxedPool boxedLine2DEquationPool = new(2); public static ITween TweenLine2DEquation(this Line2DEquation initialLine2DEquation, ITweenManager tweenManager, float duration, Line2DEquation targetLine2DEquation, System.Action setMethod) { Boxed boxedInitial = boxedLine2DEquationPool.Get(initialLine2DEquation); Boxed boxedTarget = boxedLine2DEquationPool.Get(targetLine2DEquation); ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke( new Line2DEquation( boxedInitial.Value.Slope.Lerp(boxedTarget.Value.Slope, t), boxedInitial.Value.OffsetY.Lerp(boxedTarget.Value.OffsetY, t) ) ) ); tween.OnComplete(() => { boxedLine2DEquationPool.Return(boxedInitial); boxedLine2DEquationPool.Return(boxedTarget); }); return tween; } }