feat(battle-engine): copy-loop closure to 3282 files (member-surface frontier)
This commit is contained in:
45
SVSim.BattleEngine/Engine/Wizard/TweenPositionWithUpdate.cs
Normal file
45
SVSim.BattleEngine/Engine/Wizard/TweenPositionWithUpdate.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Wizard;
|
||||
|
||||
public class TweenPositionWithUpdate : TweenPosition
|
||||
{
|
||||
private Action<float> _onUpdate;
|
||||
|
||||
public static TweenPosition Begin(GameObject go, float duration, Vector3 pos, Action<float> onUpdate)
|
||||
{
|
||||
TweenPositionWithUpdate tweenPositionWithUpdate = UITweener.Begin<TweenPositionWithUpdate>(go, duration);
|
||||
tweenPositionWithUpdate.from = tweenPositionWithUpdate.value;
|
||||
tweenPositionWithUpdate.to = pos;
|
||||
if (duration <= 0f)
|
||||
{
|
||||
tweenPositionWithUpdate.Sample(1f, isFinished: true);
|
||||
tweenPositionWithUpdate.enabled = false;
|
||||
}
|
||||
tweenPositionWithUpdate._onUpdate = onUpdate;
|
||||
return tweenPositionWithUpdate;
|
||||
}
|
||||
|
||||
public static TweenPosition Begin(GameObject go, float duration, Vector3 pos, bool worldSpace, Action<float> onUpdate)
|
||||
{
|
||||
TweenPositionWithUpdate tweenPositionWithUpdate = UITweener.Begin<TweenPositionWithUpdate>(go, duration);
|
||||
tweenPositionWithUpdate.worldSpace = worldSpace;
|
||||
tweenPositionWithUpdate.from = tweenPositionWithUpdate.value;
|
||||
tweenPositionWithUpdate.to = pos;
|
||||
if (duration <= 0f)
|
||||
{
|
||||
tweenPositionWithUpdate.Sample(1f, isFinished: true);
|
||||
tweenPositionWithUpdate.enabled = false;
|
||||
}
|
||||
tweenPositionWithUpdate._onUpdate = onUpdate;
|
||||
return tweenPositionWithUpdate;
|
||||
}
|
||||
|
||||
protected override void OnUpdate(float factor, bool isFinished)
|
||||
{
|
||||
base.value = from * (1f - factor) + to * factor;
|
||||
_onUpdate.Call(factor);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user