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:
gamer147
2026-07-03 19:18:54 -04:00
parent 5c1db83967
commit 2d9a6eea4b
2045 changed files with 11704 additions and 158495 deletions

View File

@@ -81,7 +81,7 @@ public class PuzzleBattleManager : BattleManagerBase
public override VfxBase Setup()
{
GameMgr.GetIns().GetSoundMgr().SeMute(isMute: true);
return base.Setup();
}
@@ -100,7 +100,7 @@ public class PuzzleBattleManager : BattleManagerBase
public override VfxBase Setup()
{
PuzzleGenerator puzzleGenerator = new PuzzleGenerator();
PuzzleGenerator puzzleGenerator = new PuzzleGenerator(_battleMgr as PuzzleBattleManager);
PuzzleQuestData puzzleQuestData = (_battleMgr as PuzzleBattleManager).PuzzleQuestData;
return SequentialVfxPlayer.Create(new PuzzleOpeningVfx(_battleMgr.BackGround), InstantVfx.Create(delegate
{
@@ -110,12 +110,12 @@ public class PuzzleBattleManager : BattleManagerBase
puzzleBattleManager.SetUpResetAndFailedAnimation();
puzzleBattleManager.SetReaperCard();
_battleMgr.VfxMgr.RegisterSequentialVfx(puzzleGenerator.Generate(puzzleQuestData));
_battleMgr.VfxMgr.RegisterSequentialVfx(new BattleLoadingEndVfx(_battleMgr));
_battleMgr.VfxMgr.RegisterSequentialVfx(NullVfx.GetInstance());
_battleMgr.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
if (!PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.SOUND_MUTE))
{
GameMgr.GetIns().GetSoundMgr().SeMute(isMute: false);
}
_battleMgr.BackGround.PlayBgm();
}));
@@ -167,12 +167,14 @@ public class PuzzleBattleManager : BattleManagerBase
playerClass.SelfBattlePlayer.HandControl.SetHandPosition();
enemyClass.SelfBattlePlayer.HandControl.SetHandPosition();
}));
string path = GameMgr.GetIns().GetDataMgr().GetPlayerSkinId()
// Nested PuzzleOpeningVfx: no mgr in scope on the nested class; the outer mgr's leader-skin
// lookup routes through the players' BattleMgr chain instead of the static GameMgr.GetIns.
string path = playerClass.SelfBattlePlayer.BattleMgr.GameMgr.GetDataMgr().GetPlayerSkinId()
.ToString("00");
string path2 = GameMgr.GetIns().GetDataMgr().GetEnemySkinId()
string path2 = enemyClass.SelfBattlePlayer.BattleMgr.GameMgr.GetDataMgr().GetEnemySkinId()
.ToString("00");
Register(new WaitLoadResourceVfx(Toolbox.ResourcesManager.GetAssetTypePath(path, ResourcesManager.AssetLoadPathType.ClassCharaBase)));
Register(new WaitLoadResourceVfx(Toolbox.ResourcesManager.GetAssetTypePath(path2, ResourcesManager.AssetLoadPathType.ClassCharaBase)));
Register(NullVfx.GetInstance());
Register(NullVfx.GetInstance());
}
}
@@ -212,10 +214,6 @@ public class PuzzleBattleManager : BattleManagerBase
public bool IsClearDialogWaiting = true;
private const string RESET_BTN_NORMAL_SPRITE = "btn_common_02_s_off";
private const string RESET_BTN_PRESS_SPRITE = "btn_common_02_s_on";
private PuzzleAnimation _puzzleResetAnimatinon;
private PuzzleAnimation _puzzleFaledAnimatinon;
@@ -249,8 +247,8 @@ public class PuzzleBattleManager : BattleManagerBase
public PuzzleBattleManager()
: base(new PuzzleBattleMgrContentsCreator())
{
PuzzleQuestData = Data.Master.PuzzleQuestDataList.First((PuzzleQuestData data) => data.Id == GameMgr.GetIns().GetDataMgr().PuzzleQuestId);
PuzzleDifficulty = GameMgr.GetIns().GetDataMgr().PuzzleDifficulty;
PuzzleQuestData = Data.Master.PuzzleQuestDataList.First((PuzzleQuestData data) => data.Id == this.GameMgr.GetDataMgr().PuzzleQuestId);
PuzzleDifficulty = this.GameMgr.GetDataMgr().PuzzleDifficulty;
}
protected override void SetupEvent()
@@ -264,7 +262,7 @@ public class PuzzleBattleManager : BattleManagerBase
base.BattleUIContainer.ForceDisableMenu();
BattlePlayer.PlayerBattleView.HideDetailPanel();
SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
CanNotTouchCardVfx canNotTouchCardVfx = new CanNotTouchCardVfx();
VfxBase canNotTouchCardVfx = NullVfx.GetInstance();
base.VfxMgr.RegisterImmediateVfx(canNotTouchCardVfx);
sequentialVfxPlayer.Register(InstantVfx.Create(delegate
{
@@ -290,16 +288,15 @@ public class PuzzleBattleManager : BattleManagerBase
};
}
private void ForceReset(CanNotTouchCardVfx canNotTouchCardVfx)
private void ForceReset(VfxBase canNotTouchCardVfx)
{
if (_isReseting || IsBattleEnd)
{
canNotTouchCardVfx.End();
return;
}
RetryCount++;
_isReseting = true;
PuzzleGenerator puzzleGenerator = new PuzzleGenerator();
PuzzleGenerator puzzleGenerator = new PuzzleGenerator(this);
base.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
_puzzleFaledAnimatinon.Run(isReset: false);
@@ -307,7 +304,7 @@ public class PuzzleBattleManager : BattleManagerBase
base.VfxMgr.RegisterSequentialVfx(WaitVfx.Create(_puzzleFaledAnimatinon.FadeOutDuration));
base.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
GameMgr.GetIns().GetSoundMgr().SetRejectNewSound(isMute: true);
}));
base.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
@@ -316,15 +313,11 @@ public class PuzzleBattleManager : BattleManagerBase
_puzzleFaledAnimatinon.End();
}), WaitVfx.Create(_puzzleFaledAnimatinon.FadeInDuration), InstantVfx.Create(delegate
{
GameMgr.GetIns().GetSoundMgr().SetRejectNewSound(isMute: false);
canNotTouchCardVfx.End();
MenuButtonObject.gameObject.SetActive(value: true);
base.BattleUIContainer.ForceEnableMenu();
_isReseting = false;
if (!GameMgr.GetIns().GetSoundMgr().IsPlayBGM())
{
base.BackGround.PlayBgm();
}
base.BackGround.PlayBgm();
})));
}));
}
@@ -337,8 +330,8 @@ public class PuzzleBattleManager : BattleManagerBase
}
RetryCount++;
_isReseting = true;
PuzzleGenerator puzzleGenerator = new PuzzleGenerator();
CanNotTouchCardVfx canNotTouchCardVfx = new CanNotTouchCardVfx();
PuzzleGenerator puzzleGenerator = new PuzzleGenerator(this);
VfxBase canNotTouchCardVfx = NullVfx.GetInstance();
base.VfxMgr.RegisterImmediateVfx(canNotTouchCardVfx);
base.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
@@ -347,7 +340,7 @@ public class PuzzleBattleManager : BattleManagerBase
base.VfxMgr.RegisterSequentialVfx(WaitVfx.Create(_puzzleResetAnimatinon.FadeOutDuration));
base.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
GameMgr.GetIns().GetSoundMgr().SetRejectNewSound(isMute: true);
}));
base.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
@@ -356,8 +349,7 @@ public class PuzzleBattleManager : BattleManagerBase
_puzzleResetAnimatinon.End();
}), WaitVfx.Create(_puzzleResetAnimatinon.FadeInDuration), InstantVfx.Create(delegate
{
GameMgr.GetIns().GetSoundMgr().SetRejectNewSound(isMute: false);
canNotTouchCardVfx.End();
_isReseting = false;
})));
}));
@@ -409,7 +401,7 @@ public class PuzzleBattleManager : BattleManagerBase
if (!CheckWinCondition() && (BattlePlayer.Class.IsDead || BattleEnemy.Class.IsDead))
{
SequentialVfxPlayer.Create();
CanNotTouchCardVfx canNotTouchCardVfx = new CanNotTouchCardVfx();
VfxBase canNotTouchCardVfx = NullVfx.GetInstance();
base.VfxMgr.RegisterImmediateVfx(canNotTouchCardVfx);
BattlePlayer.PlayerBattleView.TurnEndButtonUI.HideBtn();
base.BattleUIContainer.ForceDisableMenu();
@@ -465,7 +457,7 @@ public class PuzzleBattleManager : BattleManagerBase
private void CreateButton()
{
GameObject gameObject = NGUITools.AddChild(base.BattleUIContainer.gameObject, LoadPrefab("Prefab/UI/HintBtn"));
gameObject.GetComponent<UIAnchor>().uiCamera = GameMgr.GetIns().GetGameObjMgr().GetUIContainerCam();
gameObject.GetComponent<UIAnchor>().uiCamera = this.GameMgr.GetGameObjMgr().GetUIContainerCam();
UISprite componentInChildren = gameObject.GetComponentInChildren<UISprite>();
componentInChildren.atlas = UIManager.GetInstance().GetAtlasList().FirstOrDefault((UIAtlas s) => s.name == "Battle");
componentInChildren.spriteName = "battle_btn_hint_off";
@@ -475,7 +467,7 @@ public class PuzzleBattleManager : BattleManagerBase
HintButton.onClick.Clear();
HintButton.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetTitleLabel(Data.SystemText.Get("Puzzle_Hint_Title"));
dialogBase.SetSize(DialogBase.Size.M);
@@ -486,12 +478,12 @@ public class PuzzleBattleManager : BattleManagerBase
dialogBase.SetObj(gameObject3);
}));
GameObject gameObject2 = NGUITools.AddChild(base.BattleUIContainer.gameObject, LoadPrefab("Prefab/UI/PuzzleResetBtn"));
gameObject2.GetComponent<UIAnchor>().uiCamera = GameMgr.GetIns().GetGameObjMgr().GetUIContainerCam();
gameObject2.GetComponent<UIAnchor>().uiCamera = this.GameMgr.GetGameObjMgr().GetUIContainerCam();
ResetButton = gameObject2.GetComponentInChildren<UIButton>();
ResetButton.onClick.Clear();
ResetButton.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
BattlePlayer.PlayerBattleView.TurnEndButtonUI.HideBtn();
base.BattleUIContainer.SetEnableReset(isEnable: false);
BattlePlayer.PlayerBattleView.HideDetailPanel();
@@ -516,11 +508,13 @@ public class PuzzleBattleManager : BattleManagerBase
ReaperCard = CardHolder.transform.GetChild(GetMaxDeckCount(isSelf: true)).gameObject;
}
// Static helper with no mgr in scope; must fall back to GameMgr.GetIns(). A per-instance
// LoadPrefab would need a mgr ref threaded through every static caller — deferred to a
// larger cleanup pass.
private static GameObject LoadPrefab(string path)
{
PrefabMgr prefabMgr = GameMgr.GetIns().GetPrefabMgr();
prefabMgr.Load(path);
return prefabMgr.Get(path);
// Pre-Phase-5b: PrefabMgr is a UI-only shim headless
return null;
}
public void ShowResetAndHintButton()
@@ -537,7 +531,7 @@ public class PuzzleBattleManager : BattleManagerBase
public override void DisposeBattleGameObj()
{
GameMgr.GetIns().IsPuzzleQuest = false;
// GameMgr.IsPuzzleQuest is const-false in headless (Phase 4) — write dropped.
base.DisposeBattleGameObj();
}
}