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
		
			
				
	
	
		
			25 lines
		
	
	
		
			745 B
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			745 B
		
	
	
	
		
			C#
		
	
	
	
	
	
using Engine.Core;
 | 
						|
 | 
						|
namespace Engine.Systems.Tween;
 | 
						|
 | 
						|
public static class TweenCamera2DExtensions
 | 
						|
{
 | 
						|
    private static readonly BoxedPool<float> boxedFloatPool = new(2);
 | 
						|
 | 
						|
    public static ITween TweenZoom(this ICamera2D camera2D, ITweenManager tweenManager, float duration, float targetZoom)
 | 
						|
    {
 | 
						|
        Boxed<float> boxedInitial = boxedFloatPool.Get(camera2D.Zoom);
 | 
						|
        Boxed<float> boxedTarget = boxedFloatPool.Get(targetZoom);
 | 
						|
 | 
						|
        ITween tween = tweenManager.StartTween(duration, t => camera2D.Zoom = boxedInitial.Value.Lerp(boxedTarget.Value, t));
 | 
						|
 | 
						|
        tween.OnComplete(() =>
 | 
						|
        {
 | 
						|
            boxedFloatPool.Return(boxedInitial);
 | 
						|
            boxedFloatPool.Return(boxedTarget);
 | 
						|
        });
 | 
						|
 | 
						|
        return tween;
 | 
						|
    }
 | 
						|
}
 |