32 lines
980 B
C#
32 lines
980 B
C#
using Engine.Core;
|
|
|
|
namespace Engine.Systems.Tween;
|
|
|
|
public static class TweenLine3DExtensions
|
|
{
|
|
private static readonly BoxedPool<Line3D> boxedLine3DPool = new(2);
|
|
|
|
public static ITween TweenLine3D(this Line3D initialLine3D, ITweenManager tweenManager, float duration, Line3D targetLine3D, System.Action<Line3D> setMethod)
|
|
{
|
|
Boxed<Line3D> boxedInitial = boxedLine3DPool.Get(initialLine3D);
|
|
Boxed<Line3D> boxedTarget = boxedLine3DPool.Get(targetLine3D);
|
|
|
|
ITween tween = tweenManager.StartTween(duration,
|
|
t => setMethod?.Invoke(
|
|
new Line3D(
|
|
boxedInitial.Value.From.Lerp(boxedTarget.Value.From, t),
|
|
boxedInitial.Value.To.Lerp(boxedTarget.Value.To, t)
|
|
)
|
|
)
|
|
);
|
|
|
|
tween.OnComplete(() =>
|
|
{
|
|
boxedLine3DPool.Return(boxedInitial);
|
|
boxedLine3DPool.Return(boxedTarget);
|
|
});
|
|
|
|
return tween;
|
|
}
|
|
}
|