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:
@@ -1,252 +1,7 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Cute;
|
||||
using UnityEngine;
|
||||
using Wizard;
|
||||
using Wizard.Story;
|
||||
using Wizard.Story.ChapterSelection.SelectionProcessing.BattleResult;
|
||||
|
||||
public class StoryNextSceneSelector : INextSceneSelector
|
||||
{
|
||||
private BattleResultUIController m_battleResultNewControl;
|
||||
|
||||
private const int BUILD_DECK_RENTAL_LOSE_COUNT = 2;
|
||||
|
||||
private const float INTERVAL_OPEN_DIALOG = 0.1f;
|
||||
|
||||
private bool _isEnableDeckRentalAssist;
|
||||
|
||||
private bool _isWin;
|
||||
|
||||
private int _loseCount;
|
||||
|
||||
private readonly IProcessing _firstSelectionProcessing;
|
||||
|
||||
private static bool _isHistoryOfUsingTrialDeck;
|
||||
|
||||
private SelectedStoryInfo SelectedStoryInfo => Data.SelectedStoryInfo;
|
||||
|
||||
private UIManager.ViewScene ChapterSelectionView => SelectedStoryInfo.ChapterSelectionView;
|
||||
|
||||
private static KeyValuePair<string, int> DeckRentalPlayerPrefsKey => new KeyValuePair<string, int>($"{PlayerPrefsWrapper.STORY_BATTLE_LOSE_COUNT}{Data.SelectedStoryInfo.StoryId}", 0);
|
||||
|
||||
public StoryNextSceneSelector(BattleResultUIController battleResultControl)
|
||||
{
|
||||
m_battleResultNewControl = battleResultControl;
|
||||
_loseCount = GetDeckRentalLoseCount();
|
||||
_firstSelectionProcessing = CreateSelectionProcessings();
|
||||
}
|
||||
|
||||
public static int GetDeckRentalLoseCount()
|
||||
{
|
||||
return PlayerPrefsWrapper.GetValue(DeckRentalPlayerPrefsKey);
|
||||
}
|
||||
|
||||
public static void SetDeckRentalLoseCount(int loseCount)
|
||||
{
|
||||
PlayerPrefsWrapper.SetValue(DeckRentalPlayerPrefsKey, loseCount);
|
||||
}
|
||||
|
||||
public static void ResetHistoryOfUsingPreBuildDeck()
|
||||
{
|
||||
_isHistoryOfUsingTrialDeck = false;
|
||||
}
|
||||
|
||||
public void Setup(bool isWin, GameObject gameObject)
|
||||
{
|
||||
_isWin = isWin;
|
||||
if (Data.StoryInfo.IsPreBuildDeck)
|
||||
{
|
||||
GameMgr.GetIns().GetDataMgr().LastSelectDeckAttributeType = DeckAttributeType.BuildDeck;
|
||||
}
|
||||
_isHistoryOfUsingTrialDeck = _isHistoryOfUsingTrialDeck || Data.StoryInfo.IsTrialDeck;
|
||||
if (!isWin)
|
||||
{
|
||||
Data.StoryInfo.IsPreBuildDeck = false;
|
||||
}
|
||||
int num = 0;
|
||||
if (IsEnableDeckRentalStory() && !isWin)
|
||||
{
|
||||
num = _loseCount + 1;
|
||||
}
|
||||
if (IsEnableDeckRentalStory() && num >= 2 && !_isHistoryOfUsingTrialDeck)
|
||||
{
|
||||
_isEnableDeckRentalAssist = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowResult(isWin);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowResult(bool isWin)
|
||||
{
|
||||
m_battleResultNewControl.MissionBtnObj.labels[0].text = Data.SystemText.Get("Battle_0200");
|
||||
m_battleResultNewControl.MissionBtnObj.buttons[0].onClick.Clear();
|
||||
m_battleResultNewControl.MissionBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
|
||||
UIManager.GetInstance().createInSceneCenterLoading();
|
||||
MissionInfoTask missionInfoTask = GameMgr.GetIns().GetMissionInfoTask();
|
||||
missionInfoTask.SetParameter();
|
||||
m_battleResultNewControl.StartCoroutine(Toolbox.NetworkManager.Connect(missionInfoTask, delegate
|
||||
{
|
||||
m_battleResultNewControl.CreateMissionList();
|
||||
}, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
|
||||
}));
|
||||
m_battleResultNewControl.HomeBtnObj.buttons[0].onClick.Clear();
|
||||
m_battleResultNewControl.RetryBtnObj.buttons[0].onClick.Clear();
|
||||
if (isWin)
|
||||
{
|
||||
m_battleResultNewControl.HomeBtnObj.gameObject.SetActive(value: false);
|
||||
m_battleResultNewControl.RetryBtnObj.labels[0].text = Data.SystemText.Get("Story_0004");
|
||||
m_battleResultNewControl.RetryBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE_TRANS);
|
||||
if (isWin)
|
||||
{
|
||||
GameMgr.GetIns().GetBattleCtrl().BattleEnd(UIManager.ViewScene.Scenario2);
|
||||
}
|
||||
}));
|
||||
return;
|
||||
}
|
||||
m_battleResultNewControl.HomeBtnObj.labels[0].text = Data.SystemText.Get("Story_0002");
|
||||
m_battleResultNewControl.HomeBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_CANCEL_TRANS);
|
||||
GameMgr.GetIns().GetBattleCtrl().BattleEnd(ChapterSelectionView);
|
||||
}));
|
||||
m_battleResultNewControl.RetryBtnObj.labels[0].text = Data.SystemText.Get("Battle_0204");
|
||||
m_battleResultNewControl.RetryBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
|
||||
{
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
|
||||
CreateDeckSelectForStory();
|
||||
}));
|
||||
}
|
||||
|
||||
private void ShowDeckRentalConfirmDialog()
|
||||
{
|
||||
SystemText systemText = Data.SystemText;
|
||||
DialogBase dialogBase = UIManager.GetInstance().CreateConfirmationDialog(systemText.Get("Story_0054"));
|
||||
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
|
||||
dialogBase.SetTitleLabel(systemText.Get("Story_0053"));
|
||||
dialogBase.SetButtonText(systemText.Get("Story_0055"), systemText.Get("Common_0005"));
|
||||
dialogBase.onPushButton1 = delegate
|
||||
{
|
||||
CreateDeckSelectForStoryWithPrimaryTrialDeck();
|
||||
};
|
||||
dialogBase.onPushButton2 = delegate
|
||||
{
|
||||
DeckRentalFinish();
|
||||
};
|
||||
dialogBase.onCloseWithoutSelect = delegate
|
||||
{
|
||||
DeckRentalFinish();
|
||||
};
|
||||
}
|
||||
|
||||
private void DeckRentalFinish()
|
||||
{
|
||||
if (!Data.StoryInfo.IsTrialDeck)
|
||||
{
|
||||
SetDeckRentalLoseCount(0);
|
||||
ShowResult(_isWin);
|
||||
ResultMenuAppearAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
public void CreateDeckSelectForStory()
|
||||
{
|
||||
Parameter param = new Parameter(UIManager.GetInstance(), SelectedStoryInfo, (Format)PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.LAST_SELECT_DECK_FORMAT), DeckAttributeType.Invalid, null, null);
|
||||
ExecuteSelectionProcessings(param);
|
||||
}
|
||||
|
||||
private void CreateDeckSelectForStoryWithPrimaryTrialDeck()
|
||||
{
|
||||
bool isDecidedDeck = false;
|
||||
Parameter param = new Parameter(UIManager.GetInstance(), SelectedStoryInfo, Format.Max, DeckAttributeType.TrialDeck, delegate
|
||||
{
|
||||
if (!isDecidedDeck)
|
||||
{
|
||||
ShowDeckRentalConfirmDialog();
|
||||
}
|
||||
}, delegate
|
||||
{
|
||||
isDecidedDeck = true;
|
||||
});
|
||||
ExecuteSelectionProcessings(param);
|
||||
Data.StoryInfo.IsTrialDeck = false;
|
||||
}
|
||||
|
||||
private bool IsEnableDeckRentalStory()
|
||||
{
|
||||
if (SelectedStoryInfo.IsFixedDeck)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (SelectedStoryInfo.ClearStatus == StoryChapterData.ChapterClearStatus.Cleared)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private IEnumerator ShowRentalDeckCoroutine()
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
bool isWaitRewardDialog = m_battleResultNewControl.IsRewardWait;
|
||||
while (m_battleResultNewControl.IsRewardWait)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
if (isWaitRewardDialog)
|
||||
{
|
||||
yield return new WaitForSeconds(0.1f);
|
||||
}
|
||||
ShowDeckRentalConfirmDialog();
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
if (_isEnableDeckRentalAssist)
|
||||
{
|
||||
m_battleResultNewControl.StartCoroutine(ShowRentalDeckCoroutine());
|
||||
}
|
||||
else
|
||||
{
|
||||
ResultMenuAppearAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
private void ResultMenuAppearAnimation()
|
||||
{
|
||||
iTween.MoveTo(m_battleResultNewControl.ButtonGrid.gameObject, iTween.Hash("position", m_battleResultNewControl.DefaultPosDict["ButtonGrid"], "time", 0.5f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
|
||||
}
|
||||
|
||||
private static IProcessing CreateSelectionProcessings()
|
||||
{
|
||||
IProcessing[] array = new IProcessing[6]
|
||||
{
|
||||
new DeckSelectionDialogDisplay(),
|
||||
new ChapterCharaDecider(),
|
||||
new DownloadInfoGetter(),
|
||||
new DeckSelectionConfirmDialogDisplay(),
|
||||
new Download(),
|
||||
new BattleStarter()
|
||||
};
|
||||
for (int i = 0; i < array.Length - 1; i++)
|
||||
{
|
||||
array[i].NextProcessing = array[i + 1];
|
||||
}
|
||||
return array.FirstOrDefault();
|
||||
}
|
||||
|
||||
private void ExecuteSelectionProcessings(Parameter param)
|
||||
{
|
||||
if (_firstSelectionProcessing != null)
|
||||
{
|
||||
_firstSelectionProcessing.Execute(param);
|
||||
}
|
||||
}
|
||||
}
|
||||
// PASS-8/Phase-1 STUB: 200-line client-side story next-scene selector reduced to the
|
||||
// external static-method surface. `ResetHistoryOfUsingPreBuildDeck` is called from
|
||||
// AreaSelectUI.cs:492,543 (also stubbed). No instantiations anywhere.
|
||||
public class StoryNextSceneSelector
|
||||
{
|
||||
public static void ResetHistoryOfUsingPreBuildDeck() { }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user