diff --git a/Engine.Systems/Tween/EngineExtensions/TweenAABBExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenAABBExtensions.cs index e0b6304..bfedd4f 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenAABBExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenAABBExtensions.cs @@ -1,10 +1,24 @@ -using System; using Engine.Core; namespace Engine.Systems.Tween; public static class TweenAABBExtensions { - public static ITween TweenAABB(this AABB initialAABB, ITweenManager tweenManager, float duration, AABB targetAABB, Action setMethod) - => tweenManager.StartTween(duration, t => setMethod?.Invoke(new AABB(initialAABB.LowerBoundary.Lerp(targetAABB.LowerBoundary, t), initialAABB.UpperBoundary.Lerp(targetAABB.UpperBoundary, t)))); + 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; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenCamera2DExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenCamera2DExtensions.cs index 32d923c..d8d3059 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenCamera2DExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenCamera2DExtensions.cs @@ -4,9 +4,21 @@ namespace Engine.Systems.Tween; public static class TweenCamera2DExtensions { + private static readonly BoxedPool boxedFloatPool = new(2); + public static ITween TweenZoom(this ICamera2D camera2D, ITweenManager tweenManager, float duration, float targetZoom) { - float initialZoom = camera2D.Zoom; - return tweenManager.StartTween(duration, t => camera2D.Zoom = initialZoom.Lerp(targetZoom, t)); + Boxed boxedInitial = boxedFloatPool.Get(camera2D.Zoom); + Boxed 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; } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenCircleExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenCircleExtensions.cs index 959ed38..f0253b6 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenCircleExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenCircleExtensions.cs @@ -4,13 +4,28 @@ namespace Engine.Systems.Tween; public static class TweenCircleExtensions { + private static readonly BoxedPool boxedCirclePool = new(2); + public static ITween TweenCircle(this Circle initialCircle, ITweenManager tweenManager, float duration, Circle targetCircle, System.Action setMethod) - => tweenManager.StartTween(duration, + { + Boxed boxedInitial = boxedCirclePool.Get(initialCircle); + Boxed boxedTarget = boxedCirclePool.Get(targetCircle); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke( new Circle( - initialCircle.Center.Lerp(targetCircle.Center, t), - initialCircle.Diameter.Lerp(targetCircle.Diameter, t) + boxedInitial.Value.Center.Lerp(boxedTarget.Value.Center, t), + boxedInitial.Value.Diameter.Lerp(boxedTarget.Value.Diameter, t) ) ) ); + + tween.OnComplete(() => + { + boxedCirclePool.Return(boxedInitial); + boxedCirclePool.Return(boxedTarget); + }); + + return tween; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenColorExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenColorExtensions.cs index ce26271..3bf9216 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenColorExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenColorExtensions.cs @@ -4,6 +4,9 @@ namespace Engine.Systems.Tween; public static class TweenColorExtensions { + private static readonly BoxedPool boxedColorHSVPool = new(2); + private static readonly BoxedPool boxedColorHSVAPool = new(2); + public static ITween TweenColor(this ColorRGB initialColorRGB, ITweenManager tweenManager, float duration, ColorRGB targetColorRGB, System.Action setMethod) => TweenColor((ColorHSV)initialColorRGB, tweenManager, duration, (ColorHSV)targetColorRGB, color => setMethod?.Invoke(color)); @@ -11,8 +14,34 @@ public static class TweenColorExtensions => TweenColor((ColorHSVA)initialColorRGBA, tweenManager, duration, (ColorHSVA)targetColorRGBA, color => setMethod?.Invoke(color)); public static ITween TweenColor(this ColorHSV initialColorHSV, ITweenManager tweenManager, float duration, ColorHSV targetColorHSV, System.Action setMethod) - => tweenManager.StartTween(duration, t => setMethod?.Invoke(initialColorHSV.Lerp(targetColorHSV, t))); + { + Boxed boxedInitial = boxedColorHSVPool.Get(initialColorHSV); + Boxed boxedTarget = boxedColorHSVPool.Get(targetColorHSV); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.Lerp(boxedTarget.Value, t))); + + tween.OnComplete(() => + { + boxedColorHSVPool.Return(boxedInitial); + boxedColorHSVPool.Return(boxedTarget); + }); + + return tween; + } public static ITween TweenColor(this ColorHSVA initialColorHSVA, ITweenManager tweenManager, float duration, ColorHSVA targetColorHSVA, System.Action setMethod) - => tweenManager.StartTween(duration, t => setMethod?.Invoke(initialColorHSVA.Lerp(targetColorHSVA, t))); + { + Boxed boxedInitial = boxedColorHSVAPool.Get(initialColorHSVA); + Boxed boxedTarget = boxedColorHSVAPool.Get(targetColorHSVA); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.Lerp(boxedTarget.Value, t))); + + tween.OnComplete(() => + { + boxedColorHSVAPool.Return(boxedInitial); + boxedColorHSVAPool.Return(boxedTarget); + }); + + return tween; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenLine2DEquationExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenLine2DEquationExtensions.cs index 52e2bdc..51fc9e6 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenLine2DEquationExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenLine2DEquationExtensions.cs @@ -4,13 +4,28 @@ 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) - => tweenManager.StartTween(duration, + { + Boxed boxedInitial = boxedLine2DEquationPool.Get(initialLine2DEquation); + Boxed boxedTarget = boxedLine2DEquationPool.Get(targetLine2DEquation); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke( new Line2DEquation( - initialLine2DEquation.Slope.Lerp(targetLine2DEquation.Slope, t), - initialLine2DEquation.OffsetY.Lerp(targetLine2DEquation.OffsetY, t) + 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; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenLine2DExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenLine2DExtensions.cs index e9f5c46..a34ec4d 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenLine2DExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenLine2DExtensions.cs @@ -4,13 +4,28 @@ namespace Engine.Systems.Tween; public static class TweenLine2DExtensions { + private static readonly BoxedPool boxedLine2DPool = new(2); + public static ITween TweenLine2D(this Line2D initialLine2D, ITweenManager tweenManager, float duration, Line2D targetLine2D, System.Action setMethod) - => tweenManager.StartTween(duration, + { + Boxed boxedInitial = boxedLine2DPool.Get(initialLine2D); + Boxed boxedTarget = boxedLine2DPool.Get(targetLine2D); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke( new Line2D( - initialLine2D.From.Lerp(targetLine2D.From, t), - initialLine2D.To.Lerp(targetLine2D.To, t) + 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; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenPrimitiveExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenPrimitiveExtensions.cs new file mode 100644 index 0000000..1dc857f --- /dev/null +++ b/Engine.Systems/Tween/EngineExtensions/TweenPrimitiveExtensions.cs @@ -0,0 +1,41 @@ +using Engine.Core; + +namespace Engine.Systems.Tween; + +public static class TweenPrimitiveExtensions +{ + private static readonly BoxedPool boxedFloatPool = new(2); + private static readonly BoxedPool boxedIntPool = new(2); + + public static ITween TweenFloat(this float initialFloat, ITweenManager tweenManager, float duration, float targetFloat, System.Action setMethod) + { + Boxed boxedInitial = boxedFloatPool.Get(initialFloat); + Boxed boxedTarget = boxedFloatPool.Get(targetFloat); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.Lerp(boxedTarget.Value, t))); + + tween.OnComplete(() => + { + boxedFloatPool.Return(boxedInitial); + boxedFloatPool.Return(boxedTarget); + }); + + return tween; + } + + public static ITween TweenInt(this int initialInt, ITweenManager tweenManager, float duration, int targetInt, System.Action setMethod) + { + Boxed boxedInitial = boxedIntPool.Get(initialInt); + Boxed boxedTarget = boxedIntPool.Get(targetInt); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value + (boxedTarget.Value - boxedInitial.Value) * t)); + + tween.OnComplete(() => + { + boxedIntPool.Return(boxedInitial); + boxedIntPool.Return(boxedTarget); + }); + + return tween; + } +} diff --git a/Engine.Systems/Tween/EngineExtensions/TweenProjection1DExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenProjection1DExtensions.cs index b20ba7b..b18399e 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenProjection1DExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenProjection1DExtensions.cs @@ -1,17 +1,31 @@ -using System; using Engine.Core; namespace Engine.Systems.Tween; public static class TweenProjection1DExtensions { - public static ITween TweenProjection1D(this Projection1D initialProjection1D, ITweenManager tweenManager, float duration, Projection1D targetProjection1D, Action setMethod) - => tweenManager.StartTween(duration, + 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( - initialProjection1D.Min.Lerp(targetProjection1D.Min, t), - initialProjection1D.Max.Lerp(targetProjection1D.Max, t) + 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; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenQuaternionExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenQuaternionExtensions.cs index 5397433..976c2d4 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenQuaternionExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenQuaternionExtensions.cs @@ -1,10 +1,24 @@ -using System; using Engine.Core; namespace Engine.Systems.Tween; public static class TweenQuaternionExtensions { - public static ITween TweenQuaternion(this Quaternion initialQuaternion, ITweenManager tweenManager, float duration, Quaternion targetQuaternion, Action setMethod) - => tweenManager.StartTween(duration, t => setMethod?.Invoke(initialQuaternion.SLerp(targetQuaternion, t))); + private static readonly BoxedPool boxedQuaternionPool = new(2); + + public static ITween TweenQuaternion(this Quaternion initialQuaternion, ITweenManager tweenManager, float duration, Quaternion targetQuaternion, System.Action setMethod) + { + Boxed boxedInitial = boxedQuaternionPool.Get(initialQuaternion); + Boxed boxedTarget = boxedQuaternionPool.Get(targetQuaternion); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.SLerp(boxedTarget.Value, t))); + + tween.OnComplete(() => + { + boxedQuaternionPool.Return(boxedInitial); + boxedQuaternionPool.Return(boxedTarget); + }); + + return tween; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenTransform2DExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenTransform2DExtensions.cs index c3b3e4b..62a2aac 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenTransform2DExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenTransform2DExtensions.cs @@ -5,40 +5,23 @@ namespace Engine.Systems.Tween; public static class TweenTransform2DExtensions { public static ITween TweenPosition(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetPosition) - { - Vector2D initialPosition = transform2D.Position; - return tweenManager.StartTween(duration, t => transform2D.Position = initialPosition.Lerp(targetPosition, t)); - } + => transform2D.Position.TweenVector2D(tweenManager, duration, targetPosition, x => transform2D.Position = x); public static ITween TweenScale(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetScale) - { - Vector2D initialScale = transform2D.Scale; - return tweenManager.StartTween(duration, t => transform2D.Scale = initialScale.Lerp(targetScale, t)); - } + => transform2D.Scale.TweenVector2D(tweenManager, duration, targetScale, x => transform2D.Scale = x); public static ITween TweenRotation(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float targetRotation) - { - float initialRotation = transform2D.Rotation; - return tweenManager.StartTween(duration, t => transform2D.Rotation = initialRotation.Lerp(targetRotation, t)); - } + => transform2D.Rotation.TweenFloat(tweenManager, duration, targetRotation, x => transform2D.Rotation = x); public static ITween TweenLocalPosition(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetLocalPosition) - { - Vector2D initialLocalPosition = transform2D.LocalPosition; - return tweenManager.StartTween(duration, t => transform2D.LocalPosition = initialLocalPosition.Lerp(targetLocalPosition, t)); - } + => transform2D.LocalPosition.TweenVector2D(tweenManager, duration, targetLocalPosition, x => transform2D.LocalPosition = x); public static ITween TweenLocalScale(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D targetLocalScale) - { - Vector2D initialLocalScale = transform2D.LocalScale; - return tweenManager.StartTween(duration, t => transform2D.LocalScale = initialLocalScale.Lerp(targetLocalScale, t)); - } + => transform2D.LocalScale.TweenVector2D(tweenManager, duration, targetLocalScale, x => transform2D.LocalScale = x); public static ITween TweenLocalRotation(this ITransform2D transform2D, ITweenManager tweenManager, float duration, float targetLocalRotation) - { - float initialLocalRotation = transform2D.LocalRotation; - return tweenManager.StartTween(duration, t => transform2D.LocalRotation = initialLocalRotation.Lerp(targetLocalRotation, t)); - } + => transform2D.LocalRotation.TweenFloat(tweenManager, duration, targetLocalRotation, x => transform2D.LocalRotation = x); + public static ITween TweenPositionAdditive(this ITransform2D transform2D, ITweenManager tweenManager, float duration, Vector2D additivePosition) { Vector2D progressedPosition = Vector2D.Zero; diff --git a/Engine.Systems/Tween/EngineExtensions/TweenTriangleExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenTriangleExtensions.cs index 236b46e..c1dfd1e 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenTriangleExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenTriangleExtensions.cs @@ -1,18 +1,31 @@ -using System; using Engine.Core; namespace Engine.Systems.Tween; public static class TweenTriangleExtensions { - public static ITween TweenTriangle(this Triangle initialTriangle, ITweenManager tweenManager, float duration, Triangle targetTriangle, Action setMethod) - => tweenManager.StartTween(duration, - t => setMethod?.Invoke( + private static readonly BoxedPool boxedTrianglePool = new(2); + + public static ITween TweenTriangle(this Triangle initialTriangle, ITweenManager tweenManager, float duration, Triangle targetTriangle, System.Action setMethod) + { + Boxed boxedInitial = boxedTrianglePool.Get(initialTriangle); + Boxed boxedTarget = boxedTrianglePool.Get(targetTriangle); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke( new Triangle( - initialTriangle.A.Lerp(targetTriangle.A, t), - initialTriangle.B.Lerp(targetTriangle.B, t), - initialTriangle.C.Lerp(targetTriangle.C, t) + boxedInitial.Value.A.Lerp(boxedTarget.Value.A, t), + boxedInitial.Value.B.Lerp(boxedTarget.Value.B, t), + boxedInitial.Value.C.Lerp(boxedTarget.Value.C, t) ) ) ); + + tween.OnComplete(() => + { + boxedTrianglePool.Return(boxedInitial); + boxedTrianglePool.Return(boxedTarget); + }); + + return tween; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenVector2DExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenVector2DExtensions.cs index 1ef0454..49d620f 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenVector2DExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenVector2DExtensions.cs @@ -4,6 +4,21 @@ namespace Engine.Systems.Tween; public static class TweenVector2DExtensions { + private static readonly BoxedPool boxedVector2DPool = new(2); + public static ITween TweenVector2D(this Vector2D initialVector2D, ITweenManager tweenManager, float duration, Vector2D targetVector2D, System.Action setMethod) - => tweenManager.StartTween(duration, t => setMethod?.Invoke(initialVector2D.Lerp(targetVector2D, t))); + { + Boxed boxedInitial = boxedVector2DPool.Get(initialVector2D); + Boxed boxedTarget = boxedVector2DPool.Get(targetVector2D); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.Lerp(boxedTarget.Value, t))); + + tween.OnComplete(() => + { + boxedVector2DPool.Return(boxedInitial); + boxedVector2DPool.Return(boxedTarget); + }); + + return tween; + } } diff --git a/Engine.Systems/Tween/EngineExtensions/TweenVector3DExtensions.cs b/Engine.Systems/Tween/EngineExtensions/TweenVector3DExtensions.cs index e4c53fd..3853634 100644 --- a/Engine.Systems/Tween/EngineExtensions/TweenVector3DExtensions.cs +++ b/Engine.Systems/Tween/EngineExtensions/TweenVector3DExtensions.cs @@ -4,6 +4,21 @@ namespace Engine.Systems.Tween; public static class TweenVector3DExtensions { + private static readonly BoxedPool boxedVector3DPool = new(2); + public static ITween TweenVector3D(this Vector3D initialVector3D, ITweenManager tweenManager, float duration, Vector3D targetVector3D, System.Action setMethod) - => tweenManager.StartTween(duration, t => setMethod?.Invoke(initialVector3D.Lerp(targetVector3D, t))); + { + Boxed boxedInitial = boxedVector3DPool.Get(initialVector3D); + Boxed boxedTarget = boxedVector3DPool.Get(targetVector3D); + + ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.Lerp(boxedTarget.Value, t))); + + tween.OnComplete(() => + { + boxedVector3DPool.Return(boxedInitial); + boxedVector3DPool.Return(boxedTarget); + }); + + return tween; + } } diff --git a/Engine.Systems/Tween/Helpers/Boxed.cs b/Engine.Systems/Tween/Helpers/Boxed.cs new file mode 100644 index 0000000..e02242d --- /dev/null +++ b/Engine.Systems/Tween/Helpers/Boxed.cs @@ -0,0 +1,12 @@ +using Engine.Core; + +namespace Engine.Systems.Tween; + +public class Boxed where T : struct +{ + public Event, BoxedValueChangedArguments> OnValueChanged { get; } = new(); + + public T Value { get; set; } = default; + + public readonly record struct BoxedValueChangedArguments(T PreviousValue, T CurrentValue); +} diff --git a/Engine.Systems/Tween/Helpers/BoxedPool.cs b/Engine.Systems/Tween/Helpers/BoxedPool.cs new file mode 100644 index 0000000..37fd270 --- /dev/null +++ b/Engine.Systems/Tween/Helpers/BoxedPool.cs @@ -0,0 +1,14 @@ +using Engine.Core; + +namespace Engine.Systems.Tween; + +public class BoxedPool(int initialCapacity = 1) : Pool>(() => new(), initialCapacity) where T : struct; +public static class BoxedPoolExtensions +{ + public static Boxed Get(this BoxedPool boxedPool, T value) where T : struct + { + Boxed boxed = boxedPool.Get(); + boxed.Value = value; + return boxed; + } +}