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

@@ -11,7 +11,6 @@ public class GachaUI : UIBase
public enum CardPackType
{
NONE,
CRYSTAL,
CRYSTAL_MULTI,
DAILY,
TICKET,
@@ -28,70 +27,6 @@ public class GachaUI : UIBase
private static GachaUI _gachaUiInstance;
private const int DEPTH_REWARD_DIALOG_PANEL = 600;
private const int DEPTH_REWARD_DIALOG_INNER = 610;
private const int DEPTH_SELECT_BUY_NUM_DIALOG = 610;
private const int DEPTH_TUTORIAL_BUY_CONFIRM = 1000;
private const int DEPTH_TUTORIAL_LEGEND_PACK_DETAIL_MESSAGE_DIALOG = 1000;
private const int SORTING_ORDER_TUTORIAL_LEGEND_PACK_DETAIL_MESSAGE_DIALOG = 37;
private const int ORDER_REWARD_DIALOG = 2;
public const int BASIC_PACK_ID_START = 10000;
private const int BASIC_PACK_ID_END = 14999;
public const int ADDITIONAL_PACK_ID_START = 15000;
private const int ADDITIONAL_PACK_ID_END = 15999;
private const int TS_SKIN_PICKUP_PACK_ID_START = 16000;
private const int TS_SKIN_PICKUP_PACK_ID_END = 16999;
private const int TS_ROTATION_TICKET_PACK_ID_START = 80000;
private const int TS_ROTATION_TICKET_ID = 80001;
private const int TS_ROTATION_TICKET_PACK_ID_END = 89001;
public const int LEGEND_PACK_GACHA_ID = 90001;
private const int TS_STEPUP_GACHA_FIRST_ID_START = 97000;
private const int TS_STEPUP_GACHA_FIRST_ID_END = 97999;
private const int TS_STEPUP_GACHA_SECOND_ID_START = 98000;
private const int TS_STEPUP_GACHA_SECOND_ID_END = 98999;
private const int TS_LEGEND_PACK_GACHA_ID = 99000;
private const int DEFAULT_DRUMROLL_INDEX = 0;
private const int MAX_CARD_PACK_NAM = 10;
private const int DAILY_BUY_PACK_NAM = 1;
public const int SPECIAL_CARD_PACK_NUM = 10;
public const int ROTATION_STARTER_PACK_NUM = 10;
private const string FORMAT_BTN_ROTATION_ON = "btn_gacha_timesliprotation_on";
private const string FORMAT_BTN_ROTATION_OFF = "btn_gacha_timesliprotation_off";
private const string FORMAT_BTN_UNLIMITED_ON = "btn_gacha_unlimited_on";
private const string FORMAT_BTN_UNLIMITED_OFF = "btn_gacha_unlimited_off";
public const string APPEAL_IMAGE = "card_pack_{0}_poster_sub";
[SerializeField]
private UIToggle _skipToggleBtn;
@@ -192,11 +127,6 @@ public class GachaUI : UIBase
public bool IsDuringPackOpen { get; private set; }
public static GachaUI GetInstance()
{
return _gachaUiInstance;
}
public override void onFirstStart()
{
_gachaUiInstance = this;
@@ -246,7 +176,7 @@ public class GachaUI : UIBase
if (!_isRotation)
{
SetFormat(Format.Rotation);
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
TweenAlpha.Begin(_drumrollManager.gameObject, 0f, 0f);
CreateCardPackTop(0, fade: false);
}
@@ -256,7 +186,7 @@ public class GachaUI : UIBase
if (_isRotation)
{
SetFormat(Format.Unlimited);
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
TweenAlpha.Begin(_drumrollManager.gameObject, 0f, 0f);
CreateCardPackTop(0, fade: false);
}
@@ -370,13 +300,6 @@ public class GachaUI : UIBase
}));
}
private void BackToMyPage()
{
UIManager.ChangeViewSceneParam changeViewSceneParam = new UIManager.ChangeViewSceneParam();
changeViewSceneParam.NotWait();
UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.MyPage, changeViewSceneParam);
}
private void StartLoadCardPack(PackInfoTask.PackFirstTransition packFirstTransition)
{
bool isTurorialEnd = _isTutorial && Data.Load.data._userTutorial.TutorialStep == 100;
@@ -630,7 +553,7 @@ public class GachaUI : UIBase
_isTutorial = false;
UIManager.GetInstance().StartFirstTips(FirstTips.TipsType.ShopCardPack, delegate
{
GameMgr.GetIns().GetInputMgr().isBackKeyEnable = true;
/* Pre-Phase-5b: headless has no InputMgr */
});
FirstTips.SaveFinishFirstTips(FirstTips.TipsType.GachaPointExchange);
}
@@ -712,7 +635,7 @@ public class GachaUI : UIBase
{
if (_isPackOpen)
{
GameMgr.GetIns().GetInputMgr().isBackKeyEnable = true;
/* Pre-Phase-5b: headless has no InputMgr */
}
UIManager.GetInstance().OnReadyViewScene(isFadein: true);
}
@@ -788,12 +711,12 @@ public class GachaUI : UIBase
if (_skipToggleBtn.value)
{
_isSkipOpen = true;
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_ON);
}
else
{
_isSkipOpen = false;
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_OFF);
}
}
}
@@ -842,19 +765,6 @@ public class GachaUI : UIBase
return Data.PackInfo.dataList.FindAll((PackConfig data) => IsUnlimitedCardPackId(data.PackId));
}
private bool ContainsRotationCardSet(int parentGachaId)
{
if (Data.Load.data.RotationCardSetList.Contains(parentGachaId))
{
return true;
}
if (Prerelease.Status == Prerelease.eStatus.PRE_ROTATION)
{
return Prerelease.Instance.RotationCardSetList.Contains(parentGachaId);
}
return false;
}
private bool IsBasicPackId(int packId)
{
if (10000 < packId)
@@ -1022,7 +932,7 @@ public class GachaUI : UIBase
private void OnPushExchangeGachaPoint(PackConfig packConfig)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
_gachaPointExchangeDialog.CreateGachaPointExchangeDialog(packConfig, GetPackInfoTask);
}
@@ -1034,7 +944,7 @@ public class GachaUI : UIBase
private void OnClickPurchaseButton(PackConfig packConfig, PackChildGachaInfo gachaInfo)
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
switch (gachaInfo.PackType)
{
case CardPackType.CRYSTAL_SPECIAL:
@@ -1159,7 +1069,7 @@ public class GachaUI : UIBase
PurchasePack(packConfig, gachaInfo, buyPackNum);
}));
dialogBase.SetTitleLabel(Data.SystemText.Get("Dia_BuyCard_001_Title"));
dialogBase.ClickSe_Btn1 = Se.TYPE.SYS_BTN_DECIDE_TRANS;
dialogBase.ClickSe_Btn1 = 0;
if (Data.Load.data._userTutorial.TutorialStep == 41)
{
dialogBase.SetButtonDisable(isEnableOK: false, isEnableCancel: true);
@@ -1422,7 +1332,7 @@ public class GachaUI : UIBase
{
excludeCardIds = new int[0];
}
GameMgr.GetIns().GetInputMgr().isBackKeyEnable = false;
/* Pre-Phase-5b: headless has no InputMgr */
UIManager.GetInstance().CreatFadeClose(delegate
{
UIManager.GetInstance().createInSceneLoading();