using Engine.Core; namespace Engine.Systems.Tween; public static class TweenProjection1DExtensions { private static readonly BoxedPool boxedProjection1DPool = new(2); public static ITween TweenProjection1D(this Projection1D initialProjection1D, ITweenManager tweenManager, float duration, Projection1D targetProjection1D, System.Action setMethod) { Boxed boxedInitial = boxedProjection1DPool.Get(initialProjection1D); Boxed boxedTarget = boxedProjection1DPool.Get(targetProjection1D); ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke( new Projection1D( boxedInitial.Value.Min.Lerp(boxedTarget.Value.Min, t), boxedInitial.Value.Max.Lerp(boxedTarget.Value.Max, t) ) ) ); tween.OnComplete(() => { boxedProjection1DPool.Return(boxedInitial); boxedProjection1DPool.Return(boxedTarget); }); return tween; } }