engine cleanup passes 4-7 + multi-instancing ambient rip
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>
This commit is contained in:
@@ -104,21 +104,12 @@ public class UIDrawCall : MonoBehaviour
|
||||
|
||||
public OnRenderCallback onRender;
|
||||
|
||||
private const int maxIndexBufferCache = 10;
|
||||
|
||||
private static List<int[]> mCache = new List<int[]>(10);
|
||||
|
||||
private static int[] ClipRange = null;
|
||||
|
||||
private static int[] ClipArgs = null;
|
||||
|
||||
[Obsolete("Use UIDrawCall.activeList")]
|
||||
public static BetterList<UIDrawCall> list => mActiveList;
|
||||
|
||||
public static BetterList<UIDrawCall> activeList => mActiveList;
|
||||
|
||||
public static BetterList<UIDrawCall> inactiveList => mInactiveList;
|
||||
|
||||
public int renderQueue
|
||||
{
|
||||
get
|
||||
@@ -157,18 +148,6 @@ public class UIDrawCall : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public int finalRenderQueue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!(mDynamicMat != null))
|
||||
{
|
||||
return mRenderQueue;
|
||||
}
|
||||
return mDynamicMat.renderQueue;
|
||||
}
|
||||
}
|
||||
|
||||
public Transform cachedTransform
|
||||
{
|
||||
get
|
||||
@@ -197,8 +176,6 @@ public class UIDrawCall : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public Material dynamicMaterial => mDynamicMat;
|
||||
|
||||
public Texture mainTexture
|
||||
{
|
||||
get
|
||||
@@ -231,18 +208,6 @@ public class UIDrawCall : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public int triangles
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!(mMesh != null))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return mTriangles;
|
||||
}
|
||||
}
|
||||
|
||||
public bool isClipped => mClipCount != 0;
|
||||
|
||||
private void CreateMaterial()
|
||||
@@ -360,11 +325,6 @@ public class UIDrawCall : MonoBehaviour
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetDisableLegacyShader()
|
||||
{
|
||||
mLegacyShader = false;
|
||||
}
|
||||
|
||||
private Material RebuildMaterial()
|
||||
{
|
||||
NGUITools.DestroyImmediate(mDynamicMat);
|
||||
@@ -546,105 +506,6 @@ public class UIDrawCall : MonoBehaviour
|
||||
return array2;
|
||||
}
|
||||
|
||||
private void OnWillRenderObject()
|
||||
{
|
||||
UpdateMaterials();
|
||||
if (onRender != null)
|
||||
{
|
||||
onRender(mDynamicMat ?? mMaterial);
|
||||
}
|
||||
if (mDynamicMat == null || mClipCount == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mTextureClip)
|
||||
{
|
||||
Vector4 drawCallClipRange = panel.drawCallClipRange;
|
||||
Vector2 clipSoftness = panel.clipSoftness;
|
||||
Vector2 vector = new Vector2(1000f, 1000f);
|
||||
if (clipSoftness.x > 0f)
|
||||
{
|
||||
vector.x = drawCallClipRange.z / clipSoftness.x;
|
||||
}
|
||||
if (clipSoftness.y > 0f)
|
||||
{
|
||||
vector.y = drawCallClipRange.w / clipSoftness.y;
|
||||
}
|
||||
mDynamicMat.SetVector(ClipRange[0], new Vector4((0f - drawCallClipRange.x) / drawCallClipRange.z, (0f - drawCallClipRange.y) / drawCallClipRange.w, 1f / drawCallClipRange.z, 1f / drawCallClipRange.w));
|
||||
mDynamicMat.SetTexture("_ClipTex", clipTexture);
|
||||
}
|
||||
else if (!mLegacyShader)
|
||||
{
|
||||
UIPanel parentPanel = panel;
|
||||
int num = 0;
|
||||
while (parentPanel != null)
|
||||
{
|
||||
if (parentPanel.hasClipping)
|
||||
{
|
||||
float angle = 0f;
|
||||
Vector4 drawCallClipRange2 = parentPanel.drawCallClipRange;
|
||||
if (parentPanel != panel)
|
||||
{
|
||||
Vector3 vector2 = parentPanel.cachedTransform.InverseTransformPoint(panel.cachedTransform.position);
|
||||
drawCallClipRange2.x -= vector2.x;
|
||||
drawCallClipRange2.y -= vector2.y;
|
||||
Vector3 eulerAngles = panel.cachedTransform.rotation.eulerAngles;
|
||||
Vector3 vector3 = parentPanel.cachedTransform.rotation.eulerAngles - eulerAngles;
|
||||
vector3.x = NGUIMath.WrapAngle(vector3.x);
|
||||
vector3.y = NGUIMath.WrapAngle(vector3.y);
|
||||
vector3.z = NGUIMath.WrapAngle(vector3.z);
|
||||
if (!(Mathf.Abs(vector3.x) > 0.001f))
|
||||
{
|
||||
Mathf.Abs(vector3.y);
|
||||
_ = 0.001f;
|
||||
}
|
||||
angle = vector3.z;
|
||||
}
|
||||
SetClipping(num++, drawCallClipRange2, parentPanel.clipSoftness, angle);
|
||||
}
|
||||
parentPanel = parentPanel.parentPanel;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Vector2 clipSoftness2 = panel.clipSoftness;
|
||||
Vector4 drawCallClipRange3 = panel.drawCallClipRange;
|
||||
Vector2 mainTextureOffset = new Vector2((0f - drawCallClipRange3.x) / drawCallClipRange3.z, (0f - drawCallClipRange3.y) / drawCallClipRange3.w);
|
||||
Vector2 mainTextureScale = new Vector2(1f / drawCallClipRange3.z, 1f / drawCallClipRange3.w);
|
||||
Vector2 vector4 = new Vector2(1000f, 1000f);
|
||||
if (clipSoftness2.x > 0f)
|
||||
{
|
||||
vector4.x = drawCallClipRange3.z / clipSoftness2.x;
|
||||
}
|
||||
if (clipSoftness2.y > 0f)
|
||||
{
|
||||
vector4.y = drawCallClipRange3.w / clipSoftness2.y;
|
||||
}
|
||||
mDynamicMat.mainTextureOffset = mainTextureOffset;
|
||||
mDynamicMat.mainTextureScale = mainTextureScale;
|
||||
mDynamicMat.SetVector("_ClipSharpness", vector4);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetClipping(int index, Vector4 cr, Vector2 soft, float angle)
|
||||
{
|
||||
angle *= -(float)Math.PI / 180f;
|
||||
Vector2 vector = new Vector2(1000f, 1000f);
|
||||
if (soft.x > 0f)
|
||||
{
|
||||
vector.x = cr.z / soft.x;
|
||||
}
|
||||
if (soft.y > 0f)
|
||||
{
|
||||
vector.y = cr.w / soft.y;
|
||||
}
|
||||
if (index < ClipRange.Length)
|
||||
{
|
||||
mDynamicMat.SetVector(ClipRange[index], new Vector4((0f - cr.x) / cr.z, (0f - cr.y) / cr.w, 1f / cr.z, 1f / cr.w));
|
||||
mDynamicMat.SetVector(ClipArgs[index], new Vector4(vector.x, vector.y, Mathf.Sin(angle), Mathf.Cos(angle)));
|
||||
}
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (ClipRange == null)
|
||||
@@ -669,34 +530,6 @@ public class UIDrawCall : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
mRebuildMat = true;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
depthStart = int.MaxValue;
|
||||
depthEnd = int.MinValue;
|
||||
panel = null;
|
||||
manager = null;
|
||||
mMaterial = null;
|
||||
mTexture = null;
|
||||
clipTexture = null;
|
||||
if (mRenderer != null)
|
||||
{
|
||||
mRenderer.sharedMaterials = new Material[0];
|
||||
}
|
||||
NGUITools.DestroyImmediate(mDynamicMat);
|
||||
mDynamicMat = null;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
NGUITools.DestroyImmediate(mMesh);
|
||||
mMesh = null;
|
||||
}
|
||||
|
||||
public static UIDrawCall Create(UIPanel panel, Material mat, Texture tex, Shader shader)
|
||||
{
|
||||
return Create(null, panel, mat, tex, shader);
|
||||
@@ -777,19 +610,6 @@ public class UIDrawCall : MonoBehaviour
|
||||
mInactiveList.Clear();
|
||||
}
|
||||
|
||||
public static int Count(UIPanel panel)
|
||||
{
|
||||
int num = 0;
|
||||
for (int i = 0; i < mActiveList.size; i++)
|
||||
{
|
||||
if (mActiveList[i].manager == panel)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static void Destroy(UIDrawCall dc)
|
||||
{
|
||||
if (!dc)
|
||||
|
||||
Reference in New Issue
Block a user