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>
279 lines
5.9 KiB
C#
279 lines
5.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
[AddComponentMenu("NGUI/Interaction/Grid")]
|
|
public class UIGrid : UIWidgetContainer
|
|
{
|
|
public delegate void OnReposition();
|
|
|
|
public enum Arrangement
|
|
{
|
|
Horizontal,
|
|
CellSnap
|
|
}
|
|
|
|
public enum Sorting
|
|
{
|
|
None,
|
|
Alphabetic,
|
|
Horizontal,
|
|
Vertical,
|
|
Custom
|
|
}
|
|
|
|
public Arrangement arrangement;
|
|
|
|
public Sorting sorting;
|
|
|
|
public UIWidget.Pivot pivot;
|
|
|
|
public int maxPerLine;
|
|
|
|
public float cellWidth = 200f;
|
|
|
|
public float cellHeight = 200f;
|
|
|
|
public bool animateSmoothly;
|
|
|
|
public bool hideInactive;
|
|
|
|
public bool keepWithinPanel;
|
|
|
|
public OnReposition onReposition;
|
|
|
|
public Comparison<Transform> onCustomSort;
|
|
|
|
[HideInInspector]
|
|
[SerializeField]
|
|
private bool sorted;
|
|
|
|
protected bool mReposition;
|
|
|
|
protected UIPanel mPanel;
|
|
|
|
protected bool mInitDone;
|
|
|
|
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 && arrangement != Arrangement.CellSnap)
|
|
{
|
|
if (sorting == Sorting.Alphabetic)
|
|
{
|
|
list.Sort(SortByName);
|
|
}
|
|
else if (sorting == Sorting.Horizontal)
|
|
{
|
|
list.Sort(SortHorizontal);
|
|
}
|
|
else if (sorting == Sorting.Vertical)
|
|
{
|
|
list.Sort(SortVertical);
|
|
}
|
|
else if (onCustomSort != null)
|
|
{
|
|
list.Sort(onCustomSort);
|
|
}
|
|
else
|
|
{
|
|
Sort(list);
|
|
}
|
|
}
|
|
return list;
|
|
}
|
|
|
|
public void AddChild(Transform trans)
|
|
{
|
|
AddChild(trans, sort: true);
|
|
}
|
|
|
|
public void AddChild(Transform trans, bool sort)
|
|
{
|
|
if (trans != null)
|
|
{
|
|
trans.parent = base.transform;
|
|
ResetPosition(GetChildList());
|
|
}
|
|
}
|
|
|
|
public bool RemoveChild(Transform t)
|
|
{
|
|
List<Transform> childList = GetChildList();
|
|
if (childList.Remove(t))
|
|
{
|
|
ResetPosition(childList);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
protected virtual void Init()
|
|
{
|
|
mInitDone = true;
|
|
mPanel = NGUITools.FindInParents<UIPanel>(base.gameObject);
|
|
}
|
|
|
|
public static int SortByName(Transform a, Transform b)
|
|
{
|
|
return string.Compare(a.name, b.name);
|
|
}
|
|
|
|
public static int SortHorizontal(Transform a, Transform b)
|
|
{
|
|
return a.localPosition.x.CompareTo(b.localPosition.x);
|
|
}
|
|
|
|
public static int SortVertical(Transform a, Transform b)
|
|
{
|
|
return b.localPosition.y.CompareTo(a.localPosition.y);
|
|
}
|
|
|
|
protected virtual void Sort(List<Transform> list)
|
|
{
|
|
}
|
|
|
|
[ContextMenu("Execute")]
|
|
public virtual void Reposition()
|
|
{
|
|
if (Application.isPlaying && !mInitDone && NGUITools.GetActive(base.gameObject))
|
|
{
|
|
Init();
|
|
}
|
|
if (sorted)
|
|
{
|
|
sorted = false;
|
|
if (sorting == Sorting.None)
|
|
{
|
|
sorting = Sorting.Alphabetic;
|
|
}
|
|
NGUITools.SetDirty(this);
|
|
}
|
|
List<Transform> childList = GetChildList();
|
|
ResetPosition(childList);
|
|
if (keepWithinPanel)
|
|
{
|
|
ConstrainWithinPanel();
|
|
}
|
|
if (onReposition != null)
|
|
{
|
|
onReposition();
|
|
}
|
|
}
|
|
|
|
public void ConstrainWithinPanel()
|
|
{
|
|
if (mPanel != null)
|
|
{
|
|
mPanel.ConstrainTargetToBounds(base.transform, immediate: true);
|
|
UIScrollView component = mPanel.GetComponent<UIScrollView>();
|
|
if (component != null)
|
|
{
|
|
component.UpdateScrollbars(recalculateBounds: true);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected virtual void ResetPosition(List<Transform> list)
|
|
{
|
|
mReposition = false;
|
|
int num = 0;
|
|
int num2 = 0;
|
|
int num3 = 0;
|
|
int num4 = 0;
|
|
Transform transform = base.transform;
|
|
int i = 0;
|
|
for (int count = list.Count; i < count; i++)
|
|
{
|
|
Transform transform2 = list[i];
|
|
Vector3 vector = transform2.localPosition;
|
|
float z = vector.z;
|
|
if (arrangement == Arrangement.CellSnap)
|
|
{
|
|
if (cellWidth > 0f)
|
|
{
|
|
vector.x = Mathf.Round(vector.x / cellWidth) * cellWidth;
|
|
}
|
|
if (cellHeight > 0f)
|
|
{
|
|
vector.y = Mathf.Round(vector.y / cellHeight) * cellHeight;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
vector = ((arrangement == Arrangement.Horizontal) ? new Vector3(cellWidth * (float)num, (0f - cellHeight) * (float)num2, z) : new Vector3(cellWidth * (float)num2, (0f - cellHeight) * (float)num, z));
|
|
}
|
|
if (animateSmoothly && Application.isPlaying && Vector3.SqrMagnitude(transform2.localPosition - vector) >= 0.0001f)
|
|
{
|
|
SpringPosition springPosition = SpringPosition.Begin(transform2.gameObject, vector, 15f);
|
|
springPosition.updateScrollView = true;
|
|
springPosition.ignoreTimeScale = true;
|
|
}
|
|
else
|
|
{
|
|
transform2.localPosition = vector;
|
|
}
|
|
num3 = Mathf.Max(num3, num);
|
|
num4 = Mathf.Max(num4, num2);
|
|
if (++num >= maxPerLine && maxPerLine > 0)
|
|
{
|
|
num = 0;
|
|
num2++;
|
|
}
|
|
}
|
|
if (pivot == UIWidget.Pivot.TopLeft)
|
|
{
|
|
return;
|
|
}
|
|
Vector2 pivotOffset = NGUIMath.GetPivotOffset(pivot);
|
|
float num5;
|
|
float num6;
|
|
if (arrangement == Arrangement.Horizontal)
|
|
{
|
|
num5 = Mathf.Lerp(0f, (float)num3 * cellWidth, pivotOffset.x);
|
|
num6 = Mathf.Lerp((float)(-num4) * cellHeight, 0f, pivotOffset.y);
|
|
}
|
|
else
|
|
{
|
|
num5 = Mathf.Lerp(0f, (float)num4 * cellWidth, pivotOffset.x);
|
|
num6 = Mathf.Lerp((float)(-num3) * cellHeight, 0f, pivotOffset.y);
|
|
}
|
|
for (int j = 0; j < transform.childCount; j++)
|
|
{
|
|
Transform child = transform.GetChild(j);
|
|
SpringPosition component = child.GetComponent<SpringPosition>();
|
|
if (component != null)
|
|
{
|
|
component.target.x -= num5;
|
|
component.target.y -= num6;
|
|
continue;
|
|
}
|
|
Vector3 localPosition = child.localPosition;
|
|
localPosition.x -= num5;
|
|
localPosition.y -= num6;
|
|
child.localPosition = localPosition;
|
|
}
|
|
}
|
|
}
|