They still do generate a lot of garbage but with boxed value pools I made the boxes reusable, it still does generate garbage through the delegate creation, gotta find a solution for them later
		
			
				
	
	
		
			32 lines
		
	
	
		
			980 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			32 lines
		
	
	
		
			980 B
		
	
	
	
		
			C#
		
	
	
	
	
	
using Engine.Core;
 | 
						|
 | 
						|
namespace Engine.Systems.Tween;
 | 
						|
 | 
						|
public static class TweenLine2DExtensions
 | 
						|
{
 | 
						|
    private static readonly BoxedPool<Line2D> boxedLine2DPool = new(2);
 | 
						|
 | 
						|
    public static ITween TweenLine2D(this Line2D initialLine2D, ITweenManager tweenManager, float duration, Line2D targetLine2D, System.Action<Line2D> setMethod)
 | 
						|
    {
 | 
						|
        Boxed<Line2D> boxedInitial = boxedLine2DPool.Get(initialLine2D);
 | 
						|
        Boxed<Line2D> boxedTarget = boxedLine2DPool.Get(targetLine2D);
 | 
						|
 | 
						|
        ITween tween = tweenManager.StartTween(duration,
 | 
						|
            t => setMethod?.Invoke(
 | 
						|
                new Line2D(
 | 
						|
                    boxedInitial.Value.From.Lerp(boxedTarget.Value.From, t),
 | 
						|
                    boxedInitial.Value.To.Lerp(boxedTarget.Value.To, t)
 | 
						|
                )
 | 
						|
            )
 | 
						|
        );
 | 
						|
 | 
						|
        tween.OnComplete(() =>
 | 
						|
        {
 | 
						|
            boxedLine2DPool.Return(boxedInitial);
 | 
						|
            boxedLine2DPool.Return(boxedTarget);
 | 
						|
        });
 | 
						|
 | 
						|
        return tween;
 | 
						|
    }
 | 
						|
}
 |