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>
224 lines
5.5 KiB
C#
224 lines
5.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[AddComponentMenu("NGUI/Interaction/Table")]
|
|
public class UITable : UIWidgetContainer
|
|
{
|
|
public delegate void OnReposition();
|
|
|
|
public enum Direction
|
|
{
|
|
Down }
|
|
|
|
public enum Sorting
|
|
{
|
|
None,
|
|
Alphabetic,
|
|
Horizontal,
|
|
Vertical }
|
|
|
|
public int columns;
|
|
|
|
public Direction direction;
|
|
|
|
public Sorting sorting;
|
|
|
|
public UIWidget.Pivot pivot;
|
|
|
|
public UIWidget.Pivot cellAlignment;
|
|
|
|
public bool hideInactive = true;
|
|
|
|
public bool keepWithinPanel;
|
|
|
|
public Vector2 padding = Vector2.zero;
|
|
|
|
public OnReposition onReposition;
|
|
|
|
public Comparison<Transform> onCustomSort;
|
|
|
|
protected UIPanel mPanel;
|
|
|
|
protected bool mInitDone;
|
|
|
|
protected bool mReposition;
|
|
|
|
public bool repositionNow
|
|
{
|
|
set
|
|
{
|
|
if (value)
|
|
{
|
|
mReposition = true;
|
|
base.enabled = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public List<Transform> GetChildList()
|
|
{
|
|
Transform transform = base.transform;
|
|
List<Transform> list = new List<Transform>();
|
|
for (int i = 0; i < transform.childCount; i++)
|
|
{
|
|
Transform child = transform.GetChild(i);
|
|
if (!hideInactive || ((bool)child && NGUITools.GetActive(child.gameObject)))
|
|
{
|
|
list.Add(child);
|
|
}
|
|
}
|
|
if (sorting != Sorting.None)
|
|
{
|
|
if (sorting == Sorting.Alphabetic)
|
|
{
|
|
list.Sort(UIGrid.SortByName);
|
|
}
|
|
else if (sorting == Sorting.Horizontal)
|
|
{
|
|
list.Sort(UIGrid.SortHorizontal);
|
|
}
|
|
else if (sorting == Sorting.Vertical)
|
|
{
|
|
list.Sort(UIGrid.SortVertical);
|
|
}
|
|
else if (onCustomSort != null)
|
|
{
|
|
list.Sort(onCustomSort);
|
|
}
|
|
else
|
|
{
|
|
Sort(list);
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
protected virtual void Sort(List<Transform> list)
|
|
{
|
|
list.Sort(UIGrid.SortByName);
|
|
}
|
|
|
|
protected virtual void Init()
|
|
{
|
|
mInitDone = true;
|
|
mPanel = NGUITools.FindInParents<UIPanel>(base.gameObject);
|
|
}
|
|
|
|
protected void RepositionVariableSize(List<Transform> children)
|
|
{
|
|
float num = 0f;
|
|
float num2 = 0f;
|
|
int num3 = ((columns <= 0) ? 1 : (children.Count / columns + 1));
|
|
int num4 = ((columns > 0) ? columns : children.Count);
|
|
Bounds[,] array = new Bounds[num3, num4];
|
|
Bounds[] array2 = new Bounds[num4];
|
|
Bounds[] array3 = new Bounds[num3];
|
|
int num5 = 0;
|
|
int num6 = 0;
|
|
int i = 0;
|
|
for (int count = children.Count; i < count; i++)
|
|
{
|
|
Transform obj = children[i];
|
|
Bounds bounds = NGUIMath.CalculateRelativeWidgetBounds(obj, !hideInactive);
|
|
Vector3 localScale = obj.localScale;
|
|
bounds.min = Vector3.Scale(bounds.min, localScale);
|
|
bounds.max = Vector3.Scale(bounds.max, localScale);
|
|
array[num6, num5] = bounds;
|
|
array2[num5].Encapsulate(bounds);
|
|
array3[num6].Encapsulate(bounds);
|
|
if (++num5 >= columns && columns > 0)
|
|
{
|
|
num5 = 0;
|
|
num6++;
|
|
}
|
|
}
|
|
num5 = 0;
|
|
num6 = 0;
|
|
Vector2 pivotOffset = NGUIMath.GetPivotOffset(cellAlignment);
|
|
int j = 0;
|
|
for (int count2 = children.Count; j < count2; j++)
|
|
{
|
|
Transform obj2 = children[j];
|
|
Bounds bounds2 = array[num6, num5];
|
|
Bounds bounds3 = array2[num5];
|
|
Bounds bounds4 = array3[num6];
|
|
Vector3 localPosition = obj2.localPosition;
|
|
localPosition.x = num + bounds2.extents.x - bounds2.center.x;
|
|
localPosition.x -= Mathf.Lerp(0f, bounds2.max.x - bounds2.min.x - bounds3.max.x + bounds3.min.x, pivotOffset.x) - padding.x;
|
|
if (direction == Direction.Down)
|
|
{
|
|
localPosition.y = 0f - num2 - bounds2.extents.y - bounds2.center.y;
|
|
localPosition.y += Mathf.Lerp(bounds2.max.y - bounds2.min.y - bounds4.max.y + bounds4.min.y, 0f, pivotOffset.y) - padding.y;
|
|
}
|
|
else
|
|
{
|
|
localPosition.y = num2 + bounds2.extents.y - bounds2.center.y;
|
|
localPosition.y -= Mathf.Lerp(0f, bounds2.max.y - bounds2.min.y - bounds4.max.y + bounds4.min.y, pivotOffset.y) - padding.y;
|
|
}
|
|
num += bounds3.size.x + padding.x * 2f;
|
|
obj2.localPosition = localPosition;
|
|
if (++num5 >= columns && columns > 0)
|
|
{
|
|
num5 = 0;
|
|
num6++;
|
|
num = 0f;
|
|
num2 += bounds4.size.y + padding.y * 2f;
|
|
}
|
|
}
|
|
if (pivot == UIWidget.Pivot.TopLeft)
|
|
{
|
|
return;
|
|
}
|
|
pivotOffset = NGUIMath.GetPivotOffset(pivot);
|
|
Bounds bounds5 = NGUIMath.CalculateRelativeWidgetBounds(base.transform);
|
|
float num7 = Mathf.Lerp(0f, bounds5.size.x, pivotOffset.x);
|
|
float num8 = Mathf.Lerp(0f - bounds5.size.y, 0f, pivotOffset.y);
|
|
Transform transform = base.transform;
|
|
for (int k = 0; k < transform.childCount; k++)
|
|
{
|
|
Transform child = transform.GetChild(k);
|
|
SpringPosition component = child.GetComponent<SpringPosition>();
|
|
if (component != null)
|
|
{
|
|
component.target.x -= num7;
|
|
component.target.y -= num8;
|
|
continue;
|
|
}
|
|
Vector3 localPosition2 = child.localPosition;
|
|
localPosition2.x -= num7;
|
|
localPosition2.y -= num8;
|
|
child.localPosition = localPosition2;
|
|
}
|
|
}
|
|
|
|
[ContextMenu("Execute")]
|
|
public virtual void Reposition()
|
|
{
|
|
if (Application.isPlaying && !mInitDone && NGUITools.GetActive(this))
|
|
{
|
|
Init();
|
|
}
|
|
mReposition = false;
|
|
Transform target = base.transform;
|
|
List<Transform> childList = GetChildList();
|
|
if (childList.Count > 0)
|
|
{
|
|
RepositionVariableSize(childList);
|
|
}
|
|
if (keepWithinPanel && mPanel != null)
|
|
{
|
|
mPanel.ConstrainTargetToBounds(target, immediate: true);
|
|
UIScrollView component = mPanel.GetComponent<UIScrollView>();
|
|
if (component != null)
|
|
{
|
|
component.UpdateScrollbars(recalculateBounds: true);
|
|
}
|
|
}
|
|
if (onReposition != null)
|
|
{
|
|
onReposition();
|
|
}
|
|
}
|
|
}
|