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

@@ -101,20 +101,6 @@ public class MyPageItemBattle : MyPageItem
}
}
private const int FREE_MATCH_TOP_BUTTON_Y_NORMAL = 57;
private const int FREE_MATCH_TOP_BUTTON_Y_PRE_ROTATION = 163;
private readonly Vector3 RANK_ROTATION_POSITION_WITH_REWARD = new Vector3(215f, 106f, 0f);
private readonly Vector3 RANK_UNLIMITED_POSITION_WITH_REWARD = new Vector3(215f, -44f, 0f);
private const int CARD_INDEX_FREE_MATCH = 0;
private const int CARD_INDEX_RANK_MATCH = 1;
private const int CARD_INDEX_ROOM_MATCH = 2;
[SerializeField]
private UIButton _freeMatchButton;
@@ -561,7 +547,7 @@ public class MyPageItemBattle : MyPageItem
private void OnClickFormatFreeMatch(Format type)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
ShowMatchDeckSelect(type, DataMgr.BattleType.FreeBattle);
}
@@ -709,7 +695,7 @@ public class MyPageItemBattle : MyPageItem
private void OnClickFormatRankMatch(Format format)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
ShowMatchDeckSelect(format, DataMgr.BattleType.RankBattle);
}
@@ -744,7 +730,7 @@ public class MyPageItemBattle : MyPageItem
private void OnClickWinReward()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
_rewardDetailCamera.SetActive(value: true);
DialogBase obj = PurchaseRewardDialog.Create(GetWinnarRewardDialogData(), attachBottomObj: MyPageRewardDialogBoxCount.Create(_winRewardDialogBoxPrefab, Data.MyPageNotifications.data.CampaignBattleWin), cardDetail: _cardDetail, useLargeDetailDialog: true, layout: PurchaseRewardDialog.Layout.TITLE_BOTTOM, detailDialogTitleOverride: Data.SystemText.Get("Mission_0025"));
obj.SetTitleLabel(Data.SystemText.Get("MyPage_0081"));
@@ -757,7 +743,7 @@ public class MyPageItemBattle : MyPageItem
private void OnClickSpecialWinReward()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
_rewardDetailCamera.SetActive(value: true);
GetWinnarRewardDialogData();
GameObject obj = MyPageSpecialWinRewardDialog.Create(_specialWinRewardDialogBoxPrefab, base.Parent.GetNotTouchMypageCollider());
@@ -777,12 +763,12 @@ public class MyPageItemBattle : MyPageItem
public void ShowMatchDeckSelect(Format format, DataMgr.BattleType battleType)
{
Data.CurrentFormat = format;
GameMgr.GetIns().GetDataMgr().m_BattleType = battleType;
// Pre-Phase-5b: set the ambient DataMgr.m_BattleType; UI-driven state, no headless effect.
DeckInfoTask task = new DeckInfoTask();
task.SetParameter(format);
UIManager.GetInstance().StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
{
DeckSelectUIDialog.Create(DeckSelectUIDialog.GetTitleByBattleType(GameMgr.GetIns().GetDataMgr().m_BattleType), task.DeckGroupListData, format, DeckSelectUIDialog.eFormatChangeUIType.SingleFormat, isVisibleCreateNew: true, delegate(DialogBase dialog, DeckData deckData)
DeckSelectUIDialog.Create(DeckSelectUIDialog.GetTitleByBattleType(battleType), task.DeckGroupListData, format, DeckSelectUIDialog.eFormatChangeUIType.SingleFormat, isVisibleCreateNew: true, delegate(DialogBase dialog, DeckData deckData)
{
FreeAndRankMatchDeckSelectConfirmDialog.Create(dialog, deckData, isBattleEnd: false);
});
@@ -854,13 +840,13 @@ public class MyPageItemBattle : MyPageItem
_roomCreateButton.onClick.Add(new EventDelegate(delegate
{
SetRoomActionButtonEnable(isEnabled: false);
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
OnPushRoomCreateButton(isFadeOut: true);
}));
_roomJoinButton.onClick.Clear();
_roomJoinButton.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
if (base.Parent.IsEnableRoomInvite)
{
SetRoomActionButtonEnable(isEnabled: false);
@@ -875,7 +861,7 @@ public class MyPageItemBattle : MyPageItem
_roomWatchButton.onClick.Clear();
_roomWatchButton.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
StartRoomIDInput(isWatch: true);
}));
base.TopBar.SetTitleLabel(Data.SystemText.Get("RoomBattle_0001"));
@@ -927,7 +913,7 @@ public class MyPageItemBattle : MyPageItem
private void BackOnRoomCreateMenu(List<EventDelegate> tempBackButtonEvent)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
_roomCreateButton.gameObject.SetActive(value: true);
UISprite roomCreateButtonSprite = _roomCreateButton.GetComponent<UISprite>();
ResetAlphaAndRemoveTween(roomCreateButtonSprite);
@@ -981,7 +967,7 @@ public class MyPageItemBattle : MyPageItem
_roomCreateNormalBattleButton.onClick.Clear();
_roomCreateNormalBattleButton.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
OnClickRoomCreateNormalRule();
}));
bool isMaintenance = false;
@@ -995,7 +981,7 @@ public class MyPageItemBattle : MyPageItem
_roomCreate2PickBattleButton.onClick.Clear();
_roomCreate2PickBattleButton.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
OnClickRoomCreateTwoPick();
}));
bool isMaintenance2 = false;
@@ -1046,13 +1032,13 @@ public class MyPageItemBattle : MyPageItem
_roomIdInputButtonInInvite.onClick.Clear();
_roomIdInputButtonInInvite.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
StartRoomIDInput(isWatch: false);
}));
_roomInviteReceiveButton.onClick.Clear();
_roomInviteReceiveButton.onClick.Add(new EventDelegate(delegate
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
InviteGetListTask inviteGetListTask = new InviteGetListTask();
inviteGetListTask.SetParameter();
inviteGetListTask.SkipAllCuteResultCodeCheckErrorPopup();
@@ -1089,19 +1075,9 @@ public class MyPageItemBattle : MyPageItem
_roomInput.InitInputID(5);
}
public void SpecialWinRewardIconActive(bool active)
{
_rankMatchLayouts.SpecialWinRewardIcon.SetActive(active);
}
public void RedrawBattleCampaign()
{
_battleCampaignClass.RedrawAfterSpecialWinRewardOpened();
}
public IEnumerator JoinRoom(RoomConnectController.InitializeParameter param, bool isInvite)
{
bool oldBackKeyEnable = GameMgr.GetIns().GetInputMgr().isBackKeyEnable;
bool oldBackKeyEnable = false; // Pre-Phase-5b: headless has no InputMgr
base.TopBar.SetBackButtonEnable(enable: false);
_isStopSendMyPageRefreshTask = true;
yield return JoinRoomSub(param, isInvite);
@@ -1112,7 +1088,7 @@ public class MyPageItemBattle : MyPageItem
private IEnumerator JoinRoomSub(RoomConnectController.InitializeParameter param, bool isInvite)
{
UIManager.GetInstance().createInSceneCenterLoading(notBlack: true);
GameMgr.GetIns().GetDataMgr().m_BattleType = DataMgr.BattleType.RoomBattle;
// Pre-Phase-5b: set the ambient DataMgr.m_BattleType for room battle.
RoomConnectControllerInstance = new RoomConnectController(param);
yield return UIManager.GetInstance().StartCoroutine(RoomConnectControllerInstance.StartConnect());
if (RoomConnectControllerInstance.ConnectRoomResultType == RoomConnectController.ConnectRoomResult.SUCCESS)
@@ -1140,35 +1116,4 @@ public class MyPageItemBattle : MyPageItem
Data.Load.data._receiveInviteCount = 0;
}
}
public void GoToFreeMatch()
{
ShowCardPanelMenu();
RestoreCardPanelPosition();
MoveCardPanelLeftPosition(_freeMatchCardPanel.gameObject);
ShowFreeMatchFormatSelect(isPlaySe: true);
base.CardAnimation.SkipMoveAnimation();
}
public void GoToRoomMatch()
{
ShowCardPanelMenu();
RestoreCardPanelPosition();
MoveCardPanelLeftPosition(_cardPanelRoomMatch);
ShowRoomActionMenu(cutCardPanelAnimation: true);
base.CardAnimation.SkipMoveAnimation();
}
public bool IsStopSendMyPageRefreshTask()
{
if (!_isStopSendMyPageRefreshTask)
{
if (RoomConnectControllerInstance != null)
{
return RoomConnectControllerInstance.IsExistNodeErrorDialog();
}
return false;
}
return true;
}
}