Files
SVSimServer/SVSim.BattleEngine/Engine/TweenPosition.cs
gamer147 0d9d8acae0 feat(battle-engine): M1 auto-copy closure (782 battle-logic files)
Compile-driven bulk-copy loop (tools/engine-port/m1_copy_loop.py) pulled the precise reference closure of the battle-core roots, stopping at the classify god-object/View-VFX-UI boundary. 782 files; no re-explosion (M0 had estimated ~order 1000). Residual frontier = 52 shim-classified + 80 external (Unity/BCL) types to author next.
2026-06-05 16:57:20 -04:00

135 lines
2.5 KiB
C#

using System;
using UnityEngine;
[AddComponentMenu("NGUI/Tween/Tween Position")]
public class TweenPosition : UITweener
{
public Vector3 from;
public Vector3 to;
[HideInInspector]
public bool worldSpace;
private Transform mTrans;
private UIRect mRect;
public Transform cachedTransform
{
get
{
if (mTrans == null)
{
mTrans = base.transform;
}
return mTrans;
}
}
[Obsolete("Use 'value' instead")]
public Vector3 position
{
get
{
return value;
}
set
{
this.value = value;
}
}
public Vector3 value
{
get
{
if (!worldSpace)
{
return cachedTransform.localPosition;
}
return cachedTransform.position;
}
set
{
if (mRect == null || !mRect.isAnchored || worldSpace)
{
if (worldSpace)
{
cachedTransform.position = value;
}
else
{
cachedTransform.localPosition = value;
}
}
else
{
value -= cachedTransform.localPosition;
NGUIMath.MoveRect(mRect, value.x, value.y);
}
}
}
private void Awake()
{
mRect = GetComponent<UIRect>();
}
protected override void OnUpdate(float factor, bool isFinished)
{
value = from * (1f - factor) + to * factor;
}
public static TweenPosition Begin(GameObject go, float duration, Vector3 pos)
{
TweenPosition tweenPosition = UITweener.Begin<TweenPosition>(go, duration);
tweenPosition.from = tweenPosition.value;
tweenPosition.to = pos;
if (duration <= 0f)
{
tweenPosition.Sample(1f, isFinished: true);
tweenPosition.enabled = false;
}
return tweenPosition;
}
public static TweenPosition Begin(GameObject go, float duration, Vector3 pos, bool worldSpace)
{
TweenPosition tweenPosition = UITweener.Begin<TweenPosition>(go, duration);
tweenPosition.worldSpace = worldSpace;
tweenPosition.from = tweenPosition.value;
tweenPosition.to = pos;
if (duration <= 0f)
{
tweenPosition.Sample(1f, isFinished: true);
tweenPosition.enabled = false;
}
return tweenPosition;
}
[ContextMenu("Set 'From' to current value")]
public override void SetStartToCurrentValue()
{
from = value;
}
[ContextMenu("Set 'To' to current value")]
public override void SetEndToCurrentValue()
{
to = value;
}
[ContextMenu("Assume value of 'From'")]
private void SetCurrentValueToStart()
{
value = from;
}
[ContextMenu("Assume value of 'To'")]
private void SetCurrentValueToEnd()
{
value = to;
}
}