Squashes 146 commits from battle-engine-extraction. Net: 2,045 files changed, +11,896 / -158,687 lines. Ships engine passes 4-7 (dead-code cull, view-layer stub, receive-path shrink) plus the Phase-5 AsyncLocal ambient deletion that turns concurrent battles into a type-system property rather than a scope contract. ## What landed **Passes 4-7 (chunks 1-34):** Extended the Phase-4 const-false collapse into a cascading cull across the skill graph, view layer, and receive-path periphery. Six mode flags (IsWatchBattle/IsReplayBattle/IsAdmin/IsAdminWatch/IsPuzzleQuest/ IsAINetwork) became `const false`, every guarded block deleted. Field*.cs subclass ctors + BackGroundBase + ObjectChecker culled to no-ops. Mulligan family reworked to take a mgr param through IMulliganMgr.InitMulligan. Emotion/Recovery/Resource clusters null-stubbed. Prediction/OperationSimulator/ skill filters converted from static ambient reads to per-mgr reads via SkillPrm.ownerCard.SelfBattlePlayer.BattleMgr / ins.BattleMgr / this.BattleMgr. **Phase-5 ambient rip (chunks 35-47):** Deleted BattleAmbient / BattleAmbient- Context / TestBattleScope in full. Every per-battle mutable slot now lives on the mgr instance itself: mgr.InstanceIsForecast / InstanceIsRandomDraw / InstanceRecoveryInfo / InstanceViewerId / InstanceNetworkAgent / GameMgr BattleManagerBase.GetIns() returns null unconditionally; the residual static flags + 3 façades (Certification.ViewerId, Data.BattleRecoveryInfo, ToolboxGame.RealTimeNetworkAgent) are null-tolerant defaults kept for the handful of engine-internal readers that still reference their types. Zero BattleAmbient references anywhere in engine + node + tests. Added pre-seeded GameMgr ctor overload threaded through the mgr chain (BattleManagerBase → SingleBattleMgr / NetworkBattleManagerBase → NetworkStandard- BattleMgr → HeadlessBattleMgr / HeadlessNetworkBattleMgr). Fixtures build a GameMgr, seed it via HeadlessEngineEnv.SeedCharaIds/SeedNetUser, and pass it to the mgr's ctor — no ambient reach. Node side (SVSim.BattleNode/SessionBattleEngine): _ctx replaced with a plain GameMgr field; 34 `using var _ambient = BattleAmbient.Enter(_ctx)` scope wraps ripped from every accessor and mutator; EngineGlobalInit.WirePerSessionGameMgr takes GameMgr as a param and runs from SessionBattleEngine.SetupInternal BEFORE mgr construction. Test side: TestBattleScope deleted; 18 fixture [SetUp]s migrated to `HeadlessEngineEnv.EnsureProcessGlobals()`; MultiInstanceEngineTests rewritten around per-mgr construction (GetIns() → null is the pinned invariant). ## Regression fixes - **chunk-48** (MulliganCtrl): chunk-35's `= null` stubs on card lookups broke the live receive-driven Deal path (BattlePlayerBase.DrawCard NRE'd downstream of NetworkPlayerMulliganCtrl.StartMulliganVfx). Restored the three lookups via `_battlePlayer.BattleMgr.GetBattleCardIdx`. Engine tests were satisfied by the WireMulliganPhase seam; unit tests exposed the live-path gap. ## Ship state - SVSim.BattleEngine.Tests: 56/56 pass, 2 skip - SVSim.UnitTests: 1554/1554 pass (was 1523/31-fail before chunk 48) - Solution build: 0 source warnings (40 pre-existing NU1902 MessagePack CVEs in SVSim.EmulatedEntrypoint, unrelated) - Sequential PVP smoke: verified live (two back-to-back battles, no regression on cleanup/spinup) - Concurrent PVP smoke: verified live Adds tools/engine-port/ClosureAnalyzer/ — the Roslyn transitive-type-closure analyzer needed to make future cascade cleanup safe (per feedback memory "Engine cleanup needs closure tool" from the 2026-06-28 pass-3 failure). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
334 lines
6.8 KiB
C#
334 lines
6.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using AnimationOrTween;
|
|
using UnityEngine;
|
|
|
|
public abstract class UITweener : MonoBehaviour
|
|
{
|
|
public enum Method
|
|
{
|
|
EaseIn,
|
|
EaseOut,
|
|
EaseInOut,
|
|
BounceIn,
|
|
BounceOut
|
|
}
|
|
|
|
public enum Style
|
|
{
|
|
Once,
|
|
Loop,
|
|
PingPong
|
|
}
|
|
|
|
public static UITweener current;
|
|
|
|
[HideInInspector]
|
|
public Method method;
|
|
|
|
[HideInInspector]
|
|
public Style style;
|
|
|
|
[HideInInspector]
|
|
public AnimationCurve animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f));
|
|
|
|
[HideInInspector]
|
|
public bool ignoreTimeScale = true;
|
|
|
|
[HideInInspector]
|
|
public float delay;
|
|
|
|
[HideInInspector]
|
|
public float duration = 1f;
|
|
|
|
[HideInInspector]
|
|
public bool steeperCurves;
|
|
|
|
[HideInInspector]
|
|
public int tweenGroup;
|
|
|
|
[HideInInspector]
|
|
public List<EventDelegate> onFinished = new List<EventDelegate>();
|
|
|
|
[HideInInspector]
|
|
public GameObject eventReceiver;
|
|
|
|
[HideInInspector]
|
|
public string callWhenFinished;
|
|
|
|
private bool mStarted;
|
|
|
|
private float mStartTime;
|
|
|
|
private float mDuration;
|
|
|
|
private float mAmountPerDelta = 1000f;
|
|
|
|
private float mFactor;
|
|
|
|
private List<EventDelegate> mTemp;
|
|
|
|
public float amountPerDelta
|
|
{
|
|
get
|
|
{
|
|
if (mDuration != duration)
|
|
{
|
|
mDuration = duration;
|
|
mAmountPerDelta = Mathf.Abs((duration > 0f) ? (1f / duration) : 1000f) * Mathf.Sign(mAmountPerDelta);
|
|
}
|
|
return mAmountPerDelta;
|
|
}
|
|
}
|
|
|
|
public float tweenFactor
|
|
{
|
|
get
|
|
{
|
|
return mFactor;
|
|
}
|
|
set
|
|
{
|
|
mFactor = Mathf.Clamp01(value);
|
|
}
|
|
}
|
|
|
|
public Direction direction
|
|
{
|
|
get
|
|
{
|
|
if (!(amountPerDelta < 0f))
|
|
{
|
|
return Direction.Forward;
|
|
}
|
|
return Direction.Reverse;
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
float num = (ignoreTimeScale ? RealTime.deltaTime : Time.deltaTime);
|
|
float num2 = (ignoreTimeScale ? RealTime.time : Time.time);
|
|
if (!mStarted)
|
|
{
|
|
mStarted = true;
|
|
mStartTime = num2 + delay;
|
|
}
|
|
if (num2 < mStartTime)
|
|
{
|
|
return;
|
|
}
|
|
mFactor += amountPerDelta * num;
|
|
if (style == Style.Loop)
|
|
{
|
|
if (mFactor > 1f)
|
|
{
|
|
mFactor -= Mathf.Floor(mFactor);
|
|
}
|
|
}
|
|
else if (style == Style.PingPong)
|
|
{
|
|
if (mFactor > 1f)
|
|
{
|
|
mFactor = 1f - (mFactor - Mathf.Floor(mFactor));
|
|
mAmountPerDelta = 0f - mAmountPerDelta;
|
|
}
|
|
else if (mFactor < 0f)
|
|
{
|
|
mFactor = 0f - mFactor;
|
|
mFactor -= Mathf.Floor(mFactor);
|
|
mAmountPerDelta = 0f - mAmountPerDelta;
|
|
}
|
|
}
|
|
if (style == Style.Once && (duration == 0f || mFactor > 1f || mFactor < 0f))
|
|
{
|
|
mFactor = Mathf.Clamp01(mFactor);
|
|
Sample(mFactor, isFinished: true);
|
|
base.enabled = false;
|
|
if (!(current == null))
|
|
{
|
|
return;
|
|
}
|
|
UITweener uITweener = current;
|
|
current = this;
|
|
if (onFinished != null)
|
|
{
|
|
mTemp = onFinished;
|
|
onFinished = new List<EventDelegate>();
|
|
EventDelegate.Execute(mTemp);
|
|
for (int i = 0; i < mTemp.Count; i++)
|
|
{
|
|
EventDelegate eventDelegate = mTemp[i];
|
|
if (eventDelegate != null && !eventDelegate.oneShot)
|
|
{
|
|
EventDelegate.Add(onFinished, eventDelegate, eventDelegate.oneShot);
|
|
}
|
|
}
|
|
mTemp = null;
|
|
}
|
|
if (eventReceiver != null && !string.IsNullOrEmpty(callWhenFinished))
|
|
{
|
|
eventReceiver.SendMessage(callWhenFinished, this, SendMessageOptions.DontRequireReceiver);
|
|
}
|
|
current = uITweener;
|
|
}
|
|
else
|
|
{
|
|
Sample(mFactor, isFinished: false);
|
|
}
|
|
}
|
|
|
|
public void SetOnFinished(EventDelegate.Callback del)
|
|
{
|
|
EventDelegate.Set(onFinished, del);
|
|
}
|
|
|
|
public void SetOnFinished(EventDelegate del)
|
|
{
|
|
EventDelegate.Set(onFinished, del);
|
|
}
|
|
|
|
public void AddOnFinished(EventDelegate del)
|
|
{
|
|
EventDelegate.Add(onFinished, del);
|
|
}
|
|
|
|
public void RemoveOnFinished(EventDelegate del)
|
|
{
|
|
if (onFinished != null)
|
|
{
|
|
onFinished.Remove(del);
|
|
}
|
|
if (mTemp != null)
|
|
{
|
|
mTemp.Remove(del);
|
|
}
|
|
}
|
|
|
|
public void Sample(float factor, bool isFinished)
|
|
{
|
|
float num = Mathf.Clamp01(factor);
|
|
if (method == Method.EaseIn)
|
|
{
|
|
num = 1f - Mathf.Sin((float)Math.PI / 2f * (1f - num));
|
|
if (steeperCurves)
|
|
{
|
|
num *= num;
|
|
}
|
|
}
|
|
else if (method == Method.EaseOut)
|
|
{
|
|
num = Mathf.Sin((float)Math.PI / 2f * num);
|
|
if (steeperCurves)
|
|
{
|
|
num = 1f - num;
|
|
num = 1f - num * num;
|
|
}
|
|
}
|
|
else if (method == Method.EaseInOut)
|
|
{
|
|
num -= Mathf.Sin(num * ((float)Math.PI * 2f)) / ((float)Math.PI * 2f);
|
|
if (steeperCurves)
|
|
{
|
|
num = num * 2f - 1f;
|
|
float num2 = Mathf.Sign(num);
|
|
num = 1f - Mathf.Abs(num);
|
|
num = 1f - num * num;
|
|
num = num2 * num * 0.5f + 0.5f;
|
|
}
|
|
}
|
|
else if (method == Method.BounceIn)
|
|
{
|
|
num = BounceLogic(num);
|
|
}
|
|
else if (method == Method.BounceOut)
|
|
{
|
|
num = 1f - BounceLogic(1f - num);
|
|
}
|
|
OnUpdate((animationCurve != null) ? animationCurve.Evaluate(num) : num, isFinished);
|
|
}
|
|
|
|
private float BounceLogic(float val)
|
|
{
|
|
val = ((val < 0.363636f) ? (7.5685f * val * val) : ((val < 0.727272f) ? (7.5625f * (val -= 0.545454f) * val + 0.75f) : ((!(val < 0.90909f)) ? (7.5625f * (val -= 0.9545454f) * val + 63f / 64f) : (7.5625f * (val -= 0.818181f) * val + 0.9375f))));
|
|
return val;
|
|
}
|
|
|
|
public void PlayForward()
|
|
{
|
|
Play(forward: true);
|
|
}
|
|
|
|
public void PlayReverse()
|
|
{
|
|
Play(forward: false);
|
|
}
|
|
|
|
public void Play(bool forward)
|
|
{
|
|
mAmountPerDelta = Mathf.Abs(amountPerDelta);
|
|
if (!forward)
|
|
{
|
|
mAmountPerDelta = 0f - mAmountPerDelta;
|
|
}
|
|
base.enabled = true;
|
|
Update();
|
|
}
|
|
|
|
public void ResetToBeginning()
|
|
{
|
|
mStarted = false;
|
|
mFactor = ((amountPerDelta < 0f) ? 1f : 0f);
|
|
Sample(mFactor, isFinished: false);
|
|
}
|
|
|
|
protected abstract void OnUpdate(float factor, bool isFinished);
|
|
|
|
public static T Begin<T>(GameObject go, float duration) where T : UITweener
|
|
{
|
|
T val = go.GetComponent<T>();
|
|
if (val != null && val.tweenGroup != 0)
|
|
{
|
|
val = null;
|
|
T[] components = go.GetComponents<T>();
|
|
int i = 0;
|
|
for (int num = components.Length; i < num; i++)
|
|
{
|
|
val = components[i];
|
|
if (val != null && val.tweenGroup == 0)
|
|
{
|
|
break;
|
|
}
|
|
val = null;
|
|
}
|
|
}
|
|
if (val == null)
|
|
{
|
|
val = go.AddComponent<T>();
|
|
if (val == null)
|
|
{
|
|
Debug.LogError("Unable to add " + typeof(T)?.ToString() + " to " + NGUITools.GetHierarchy(go), go);
|
|
return null;
|
|
}
|
|
}
|
|
val.mStarted = false;
|
|
val.duration = duration;
|
|
val.mFactor = 0f;
|
|
val.mAmountPerDelta = Mathf.Abs(val.amountPerDelta);
|
|
val.style = Style.Once;
|
|
val.animationCurve = new AnimationCurve(new Keyframe(0f, 0f, 0f, 1f), new Keyframe(1f, 1f, 1f, 0f));
|
|
val.eventReceiver = null;
|
|
val.callWhenFinished = null;
|
|
val.enabled = true;
|
|
return val;
|
|
}
|
|
|
|
public virtual void SetStartToCurrentValue()
|
|
{
|
|
}
|
|
|
|
public virtual void SetEndToCurrentValue()
|
|
{
|
|
}
|
|
}
|