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>
408 lines
8.4 KiB
C#
408 lines
8.4 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
[AddComponentMenu("NGUI/Interaction/NGUI Progress Bar")]
|
|
public class UIProgressBar : UIWidgetContainer
|
|
{
|
|
public enum FillDirection
|
|
{
|
|
LeftToRight,
|
|
RightToLeft,
|
|
BottomToTop,
|
|
TopToBottom
|
|
}
|
|
|
|
public delegate void OnDragFinished();
|
|
|
|
public static UIProgressBar current;
|
|
|
|
public OnDragFinished onDragFinished;
|
|
|
|
public Transform thumb;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
protected UIWidget mBG;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
protected UIWidget mFG;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
protected float mValue = 1f;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
protected FillDirection mFill;
|
|
|
|
protected Transform mTrans;
|
|
|
|
protected bool mIsDirty;
|
|
|
|
protected Camera mCam;
|
|
|
|
protected float mOffset;
|
|
|
|
public int numberOfSteps;
|
|
|
|
public List<EventDelegate> onChange = new List<EventDelegate>();
|
|
|
|
public Transform cachedTransform
|
|
{
|
|
get
|
|
{
|
|
if (mTrans == null)
|
|
{
|
|
mTrans = base.transform;
|
|
}
|
|
return mTrans;
|
|
}
|
|
}
|
|
|
|
public Camera cachedCamera
|
|
{
|
|
get
|
|
{
|
|
if (mCam == null)
|
|
{
|
|
mCam = NGUITools.FindCameraForLayer(base.gameObject.layer);
|
|
}
|
|
return mCam;
|
|
}
|
|
}
|
|
|
|
public UIWidget foregroundWidget
|
|
{
|
|
get
|
|
{
|
|
return mFG;
|
|
}
|
|
set
|
|
{
|
|
if (mFG != value)
|
|
{
|
|
mFG = value;
|
|
mIsDirty = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public UIWidget backgroundWidget
|
|
{
|
|
get
|
|
{
|
|
return mBG;
|
|
}
|
|
set
|
|
{
|
|
if (mBG != value)
|
|
{
|
|
mBG = value;
|
|
mIsDirty = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public float value
|
|
{
|
|
get
|
|
{
|
|
if (numberOfSteps > 1)
|
|
{
|
|
return Mathf.Round(mValue * (float)(numberOfSteps - 1)) / (float)(numberOfSteps - 1);
|
|
}
|
|
return mValue;
|
|
}
|
|
set
|
|
{
|
|
float num = Mathf.Clamp01(value);
|
|
if (mValue == num)
|
|
{
|
|
return;
|
|
}
|
|
float num2 = this.value;
|
|
mValue = num;
|
|
if (num2 != this.value)
|
|
{
|
|
ForceUpdate();
|
|
if (NGUITools.GetActive(this) && EventDelegate.IsValid(onChange))
|
|
{
|
|
current = this;
|
|
EventDelegate.Execute(onChange);
|
|
current = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public float alpha
|
|
{
|
|
get
|
|
{
|
|
if (mFG != null)
|
|
{
|
|
return mFG.alpha;
|
|
}
|
|
if (mBG != null)
|
|
{
|
|
return mBG.alpha;
|
|
}
|
|
return 1f;
|
|
}
|
|
set
|
|
{
|
|
if (mFG != null)
|
|
{
|
|
mFG.alpha = value;
|
|
if (mFG.GetComponent<Collider>() != null)
|
|
{
|
|
mFG.GetComponent<Collider>().enabled = mFG.alpha > 0.001f;
|
|
}
|
|
else if (mFG.GetComponent<Collider2D>() != null)
|
|
{
|
|
mFG.GetComponent<Collider2D>().enabled = mFG.alpha > 0.001f;
|
|
}
|
|
}
|
|
if (mBG != null)
|
|
{
|
|
mBG.alpha = value;
|
|
if (mBG.GetComponent<Collider>() != null)
|
|
{
|
|
mBG.GetComponent<Collider>().enabled = mBG.alpha > 0.001f;
|
|
}
|
|
else if (mBG.GetComponent<Collider2D>() != null)
|
|
{
|
|
mBG.GetComponent<Collider2D>().enabled = mBG.alpha > 0.001f;
|
|
}
|
|
}
|
|
if (!(thumb != null))
|
|
{
|
|
return;
|
|
}
|
|
UIWidget component = thumb.GetComponent<UIWidget>();
|
|
if (component != null)
|
|
{
|
|
component.alpha = value;
|
|
if (component.GetComponent<Collider>() != null)
|
|
{
|
|
component.GetComponent<Collider>().enabled = component.alpha > 0.001f;
|
|
}
|
|
else if (component.GetComponent<Collider2D>() != null)
|
|
{
|
|
component.GetComponent<Collider2D>().enabled = component.alpha > 0.001f;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
protected bool isHorizontal
|
|
{
|
|
get
|
|
{
|
|
if (mFill != FillDirection.LeftToRight)
|
|
{
|
|
return mFill == FillDirection.RightToLeft;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
protected bool isInverted
|
|
{
|
|
get
|
|
{
|
|
if (mFill != FillDirection.RightToLeft)
|
|
{
|
|
return mFill == FillDirection.TopToBottom;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
protected virtual void Upgrade()
|
|
{
|
|
}
|
|
|
|
protected virtual void OnStart()
|
|
{
|
|
}
|
|
|
|
protected virtual void Update()
|
|
{
|
|
if (mIsDirty)
|
|
{
|
|
ForceUpdate();
|
|
}
|
|
}
|
|
|
|
protected float ScreenToValue(Vector2 screenPos)
|
|
{
|
|
Transform transform = cachedTransform;
|
|
Plane plane = new Plane(transform.rotation * Vector3.back, transform.position);
|
|
Ray ray = cachedCamera.ScreenPointToRay(screenPos);
|
|
if (!plane.Raycast(ray, out var enter))
|
|
{
|
|
return value;
|
|
}
|
|
return LocalToValue(transform.InverseTransformPoint(ray.GetPoint(enter)));
|
|
}
|
|
|
|
protected virtual float LocalToValue(Vector2 localPos)
|
|
{
|
|
if (mFG != null)
|
|
{
|
|
Vector3[] localCorners = mFG.localCorners;
|
|
Vector3 vector = localCorners[2] - localCorners[0];
|
|
if (isHorizontal)
|
|
{
|
|
float num = (localPos.x - localCorners[0].x) / vector.x;
|
|
if (!isInverted)
|
|
{
|
|
return num;
|
|
}
|
|
return 1f - num;
|
|
}
|
|
float num2 = (localPos.y - localCorners[0].y) / vector.y;
|
|
if (!isInverted)
|
|
{
|
|
return num2;
|
|
}
|
|
return 1f - num2;
|
|
}
|
|
return value;
|
|
}
|
|
|
|
public virtual void ForceUpdate()
|
|
{
|
|
mIsDirty = false;
|
|
bool flag = false;
|
|
if (mFG != null)
|
|
{
|
|
UIBasicSprite uIBasicSprite = mFG as UIBasicSprite;
|
|
if (isHorizontal)
|
|
{
|
|
if (uIBasicSprite != null && uIBasicSprite.type == UIBasicSprite.Type.Filled)
|
|
{
|
|
if (uIBasicSprite.fillDirection == UIBasicSprite.FillDirection.Horizontal || uIBasicSprite.fillDirection == UIBasicSprite.FillDirection.Vertical)
|
|
{
|
|
uIBasicSprite.fillDirection = UIBasicSprite.FillDirection.Horizontal;
|
|
uIBasicSprite.invert = isInverted;
|
|
}
|
|
uIBasicSprite.fillAmount = value;
|
|
}
|
|
else
|
|
{
|
|
mFG.drawRegion = (isInverted ? new Vector4(1f - value, 0f, 1f, 1f) : new Vector4(0f, 0f, value, 1f));
|
|
mFG.enabled = true;
|
|
flag = value < 0.001f;
|
|
}
|
|
}
|
|
else if (uIBasicSprite != null && uIBasicSprite.type == UIBasicSprite.Type.Filled)
|
|
{
|
|
if (uIBasicSprite.fillDirection == UIBasicSprite.FillDirection.Horizontal || uIBasicSprite.fillDirection == UIBasicSprite.FillDirection.Vertical)
|
|
{
|
|
uIBasicSprite.fillDirection = UIBasicSprite.FillDirection.Vertical;
|
|
uIBasicSprite.invert = isInverted;
|
|
}
|
|
uIBasicSprite.fillAmount = value;
|
|
}
|
|
else
|
|
{
|
|
mFG.drawRegion = (isInverted ? new Vector4(0f, 1f - value, 1f, 1f) : new Vector4(0f, 0f, 1f, value));
|
|
mFG.enabled = true;
|
|
flag = value < 0.001f;
|
|
}
|
|
}
|
|
if (thumb != null && (mFG != null || mBG != null))
|
|
{
|
|
Vector3[] array = ((mFG != null) ? mFG.localCorners : mBG.localCorners);
|
|
Vector4 vector = ((mFG != null) ? mFG.border : mBG.border);
|
|
array[0].x += vector.x;
|
|
array[1].x += vector.x;
|
|
array[2].x -= vector.z;
|
|
array[3].x -= vector.z;
|
|
array[0].y += vector.y;
|
|
array[1].y -= vector.w;
|
|
array[2].y -= vector.w;
|
|
array[3].y += vector.y;
|
|
Transform transform = ((mFG != null) ? mFG.cachedTransform : mBG.cachedTransform);
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
array[i] = transform.TransformPoint(array[i]);
|
|
}
|
|
if (isHorizontal)
|
|
{
|
|
Vector3 a = Vector3.Lerp(array[0], array[1], 0.5f);
|
|
Vector3 b = Vector3.Lerp(array[2], array[3], 0.5f);
|
|
SetThumbPosition(Vector3.Lerp(a, b, isInverted ? (1f - value) : value));
|
|
}
|
|
else
|
|
{
|
|
Vector3 a2 = Vector3.Lerp(array[0], array[3], 0.5f);
|
|
Vector3 b2 = Vector3.Lerp(array[1], array[2], 0.5f);
|
|
SetThumbPosition(Vector3.Lerp(a2, b2, isInverted ? (1f - value) : value));
|
|
}
|
|
}
|
|
if (flag)
|
|
{
|
|
mFG.enabled = false;
|
|
}
|
|
}
|
|
|
|
protected void SetThumbPosition(Vector3 worldPos)
|
|
{
|
|
Transform parent = thumb.parent;
|
|
if (parent != null)
|
|
{
|
|
worldPos = parent.InverseTransformPoint(worldPos);
|
|
worldPos.x = Mathf.Round(worldPos.x);
|
|
worldPos.y = Mathf.Round(worldPos.y);
|
|
worldPos.z = 0f;
|
|
if (Vector3.Distance(thumb.localPosition, worldPos) > 0.001f)
|
|
{
|
|
thumb.localPosition = worldPos;
|
|
}
|
|
}
|
|
else if (Vector3.Distance(thumb.position, worldPos) > 1E-05f)
|
|
{
|
|
thumb.position = worldPos;
|
|
}
|
|
}
|
|
|
|
public virtual void OnPan(Vector2 delta)
|
|
{
|
|
if (base.enabled)
|
|
{
|
|
switch (mFill)
|
|
{
|
|
case FillDirection.LeftToRight:
|
|
{
|
|
float num7 = (value = Mathf.Clamp01(mValue + delta.x));
|
|
mValue = num7;
|
|
break;
|
|
}
|
|
case FillDirection.RightToLeft:
|
|
{
|
|
float num5 = (value = Mathf.Clamp01(mValue - delta.x));
|
|
mValue = num5;
|
|
break;
|
|
}
|
|
case FillDirection.BottomToTop:
|
|
{
|
|
float num3 = (value = Mathf.Clamp01(mValue + delta.y));
|
|
mValue = num3;
|
|
break;
|
|
}
|
|
case FillDirection.TopToBottom:
|
|
{
|
|
float num = (value = Mathf.Clamp01(mValue - delta.y));
|
|
mValue = num;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|