using Engine.Core; namespace Engine.Systems.Tween; public static class TweenAABBExtensions { private static readonly BoxedPool boxedAABBPool = new(2); public static ITween TweenAABB(this AABB initialAABB, ITweenManager tweenManager, float duration, AABB targetAABB, System.Action setMethod) { Boxed boxedInitial = boxedAABBPool.Get(initialAABB); Boxed boxedTarget = boxedAABBPool.Get(targetAABB); ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(new AABB(boxedInitial.Value.LowerBoundary.Lerp(boxedTarget.Value.LowerBoundary, t), boxedInitial.Value.UpperBoundary.Lerp(boxedTarget.Value.UpperBoundary, t)))); tween.OnComplete(() => { boxedAABBPool.Return(boxedInitial); boxedAABBPool.Return(boxedTarget); }); return tween; } }