Files
SVSimServer/SVSim.BattleEngine/Engine/SpringPosition.cs
gamer147 957af3d1ec feat(battle-engine): full Unity/VFX/god-object shims + expanded copy closure (2570 files)
Authored Unity primitive/object-model shim, VFX layer (control-flow-preserving, InstantVfx never invokes its action -- headless suppression), god-object stubs (GameMgr/EffectMgr/UIManager with faithfully-extracted nested enums), View/UI/Touch tree, LitJson+BetterList+Tuple copied, third-party stubs. Discovered Roslyn header-error masking: fixing class-header type errors unmasks body references, so the true copy closure is ~2570 files (was 782 under masking). Errors: masked-25720 -> 268; our shim files compile clean. Remaining: ~50 residual shim/external types, 24 NGUI UI-base overrides, static-type fixes, plus likely 1-2 more unmask waves.
2026-06-05 17:22:20 -04:00

114 lines
2.5 KiB
C#

using UnityEngine;
[AddComponentMenu("NGUI/Tween/Spring Position")]
public class SpringPosition : MonoBehaviour
{
public delegate void OnFinished();
public static SpringPosition current;
public Vector3 target = Vector3.zero;
public float strength = 10f;
public bool worldSpace;
public bool ignoreTimeScale;
public bool updateScrollView;
public OnFinished onFinished;
[SerializeField]
[HideInInspector]
private GameObject eventReceiver;
[SerializeField]
[HideInInspector]
public string callWhenFinished;
private Transform mTrans;
private float mThreshold;
private UIScrollView mSv;
private void Start()
{
mTrans = base.transform;
if (updateScrollView)
{
mSv = NGUITools.FindInParents<UIScrollView>(base.gameObject);
}
}
private void Update()
{
float deltaTime = (ignoreTimeScale ? RealTime.deltaTime : Time.deltaTime);
if (worldSpace)
{
if (mThreshold == 0f)
{
mThreshold = (target - mTrans.position).sqrMagnitude * 0.001f;
}
mTrans.position = NGUIMath.SpringLerp(mTrans.position, target, strength, deltaTime);
if (mThreshold >= (target - mTrans.position).sqrMagnitude)
{
mTrans.position = target;
NotifyListeners();
base.enabled = false;
}
}
else
{
if (mThreshold == 0f)
{
mThreshold = (target - mTrans.localPosition).sqrMagnitude * 1E-05f;
}
mTrans.localPosition = NGUIMath.SpringLerp(mTrans.localPosition, target, strength, deltaTime);
if (mThreshold >= (target - mTrans.localPosition).sqrMagnitude)
{
mTrans.localPosition = target;
NotifyListeners();
base.enabled = false;
}
}
if (mSv != null)
{
mSv.UpdateScrollbars(recalculateBounds: true);
}
}
private void NotifyListeners()
{
current = this;
if (onFinished != null)
{
onFinished();
}
if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
{
eventReceiver.SendMessage(callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
}
current = null;
}
public static SpringPosition Begin(GameObject go, Vector3 pos, float strength)
{
SpringPosition springPosition = go.GetComponent<SpringPosition>();
if (springPosition == null)
{
springPosition = go.AddComponent<SpringPosition>();
}
springPosition.target = pos;
springPosition.strength = strength;
springPosition.onFinished = null;
if (!springPosition.enabled)
{
springPosition.mThreshold = 0f;
springPosition.enabled = true;
}
return springPosition;
}
}