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

@@ -10,331 +10,12 @@ namespace Wizard;
public class MyPageOtherButtons : UIBase
{
[SerializeField]
private GameObject _dialogNotificationMenu;
[SerializeField]
private GameObject _dialogContactMenu;
[SerializeField]
private GameObject _dialogRewardScroll;
[SerializeField]
private GameObject _dialogUserTicketCountPrefab;
[SerializeField]
private UILabel _labelVideoHosting;
[SerializeField]
private GameObject _buttonPool;
[SerializeField]
private UIGrid _girdButtons;
[SerializeField]
private UIButton _btnProfile;
[SerializeField]
private UIButton _btnFriend;
[SerializeField]
private UIButton _btnRanking;
[SerializeField]
private GameObject _achievementIcon;
[SerializeField]
private GameObject _achievementIconAndroid;
[SerializeField]
private UIButton _btnSetting;
[SerializeField]
private UIButton _btnReplay;
[SerializeField]
private UIButton _btnHelp;
[SerializeField]
private UIButton _btnGameGuide;
[SerializeField]
private UIButton _btnItemsHistory;
[SerializeField]
private UIButton _btnAchievement;
[SerializeField]
private UIButton _btnData;
[SerializeField]
private UIButton _btnAccountConnect;
[SerializeField]
private UIButton _btnContact;
[SerializeField]
private UIButton _btnNotification;
[SerializeField]
private UIButton _btnSwitchLanguage;
[SerializeField]
private UIButton _btnVideoHosting;
[SerializeField]
private UIButton _btnCodeInput;
[SerializeField]
private UIButton _btnReturnTitle;
[SerializeField]
private UIButton _btnPortalSite;
[SerializeField]
private UIButton _btnOffcialSite;
[SerializeField]
private UIButton _btnSignInOut;
[SerializeField]
private UIButton _btnTicketCount;
[SerializeField]
private UIButton _informationButton;
[SerializeField]
private GameObject _adjustSettingDialogPrefab;
[SerializeField]
private UIButton _btnAdjustSetting;
[SerializeField]
private UILabel _btnSignInOutLabel;
private const int CODE_NUMBER_MAX = 16;
private DialogBase _dialogCodeInput;
private UIInput _codeInput;
[SerializeField]
private UILabel _friendBadgeLabel;
[SerializeField]
private UIButton _smallResourceButton;
public List<UIButton> _enableOtherButtons { get; private set; }
public UIButton btnAchievement => _btnAchievement;
public UILabel FriendBadgeLabel => _friendBadgeLabel;
public UIButton FriendButton => _btnFriend;
private void Start()
{
_labelVideoHosting.text = VideoHostingUtil.GetVideoHostingSettingTitle();
}
public void Init()
{
List<UIButton> list = new List<UIButton>();
list.Add(_btnSetting);
list.Add(_btnReplay);
list.Add(_btnHelp);
list.Add(_informationButton);
list.Add(_btnGameGuide);
list.Add(_btnTicketCount);
list.Add(_btnItemsHistory);
list.Add(_btnNotification);
list.Add(_btnData);
list.Add(_btnContact);
list.Add(_btnPortalSite);
list.Add(_btnOffcialSite);
list.Add(_btnSwitchLanguage);
list.Add(_btnCodeInput);
list.Add(_btnAdjustSetting);
list.Add(_btnReturnTitle);
for (int i = 0; i < list.Count; i++)
{
list[i].transform.parent = _girdButtons.transform;
}
if (_enableOtherButtons == null)
{
_enableOtherButtons = new List<UIButton>();
}
_enableOtherButtons.Clear();
_enableOtherButtons.Add(_btnProfile);
_enableOtherButtons.Add(_btnFriend);
_enableOtherButtons.Add(_btnRanking);
_enableOtherButtons.AddRange(list);
for (int j = 0; j < _enableOtherButtons.Count; j++)
{
_enableOtherButtons[j].gameObject.SetActive(value: true);
}
base.gameObject.SetActive(value: true);
_girdButtons.Reposition();
_girdButtons.enabled = false;
_buttonPool.SetActive(value: false);
_btnAdjustSetting.onClick.Clear();
_btnAdjustSetting.onClick.Add(new EventDelegate(delegate
{
OnClickAdjustSetting();
}));
_informationButton.onClick.Clear();
_informationButton.onClick.Add(new EventDelegate(delegate
{
OnClickInformation();
}));
_smallResourceButton.onClick.Clear();
_smallResourceButton.onClick.Add(new EventDelegate(delegate
{
OnClickSmallResourceButton();
}));
}
private void OnClickSmallResourceButton()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
int beforeSetting = PlayerPrefsCache.Instance.GetValue(PlayerPrefsWrapper.SMALL_RESOURCE_STATUS);
Action onFinish = delegate
{
int value = PlayerPrefsCache.Instance.GetValue(PlayerPrefsWrapper.SMALL_RESOURCE_STATUS);
if (beforeSetting != value)
{
SoftwareReset.exec();
}
};
Action onCancel = delegate
{
};
SmallResourceSelectDialog.Create(onFinish, onCancel, isTitle: false);
}
private void OnClickInformation()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
CheckTimeSlipRotationPeriodTask task = new CheckTimeSlipRotationPeriodTask();
StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate
{
UIManager.GetInstance().WebViewHelper.OpenWebView(WebViewHelper.WebViewType.INFO);
}));
}
private void UpdateSignInOutText()
{
if (!(_btnSignInOutLabel == null))
{
SystemText systemText = Data.SystemText;
if (SocialServiceUtility.Instance.IsLoggedIn)
{
_btnSignInOutLabel.text = systemText.Get("OtherTop_0036");
}
else
{
_btnSignInOutLabel.text = systemText.Get("OtherTop_0035");
}
}
}
protected override void OnDestroy()
{
base.OnDestroy();
}
public void OnBtnProfile()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.Profile);
}
public void OnBtnFriend()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.Friend);
}
public void OnBtnRanking()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.Ranking);
}
public void OnBtnSetting()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
SettingBase.CreateDialog();
}
public void OnBtnReplay()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
ReplayInfoTask replayInfoTask = new ReplayInfoTask();
replayInfoTask.SetParameter();
StartCoroutine(Toolbox.NetworkManager.Connect(replayInfoTask, delegate
{
ReplayDialog.Create();
}));
}
public void OnBtnHelp()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
UIManager.GetInstance().WebViewHelper.OpenWebView(WebViewHelper.WebViewType.HELP);
}
public void OnBtnGameGuide()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
UIManager.GetInstance().WebViewHelper.CreateOpenURLWindow(WebViewHelper.UrlType.GAME_GUIDE);
}
public void OnBtnUserTicketCount()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetSize(DialogBase.Size.M);
dialogBase.SetTitleLabel(Data.SystemText.Get("OtherTop_0062"));
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
UserTicketCountDialog component = UnityEngine.Object.Instantiate(_dialogUserTicketCountPrefab).GetComponent<UserTicketCountDialog>();
component.Init(dialogBase);
dialogBase.SetObj(component.gameObject);
}
public void OnBtnItemHistory()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
ItemAcquireHistoryInfoTask itemAcquireHistoryInfoTask = new ItemAcquireHistoryInfoTask();
itemAcquireHistoryInfoTask.SetParameter();
StartCoroutine(Toolbox.NetworkManager.Connect(itemAcquireHistoryInfoTask, _DisplayItemHistory, BaseTask.OnRequestFailed, BaseTask.OnFailedErrorCode));
}
public void OnBtnAchievement()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
VideoHostingUtil.CheckVideoHostingAndShowAchievement(delegate
{
AchievementImpl.instance.ShowAchievements(delegate
{
UpdateSignInOutText();
});
});
}
public void OnBtnData()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
if (SingletonMonoBehaviour<VideoHostingManager>.instance.IsRecording() || SingletonMonoBehaviour<VideoHostingManager>.instance.IsPublising())
{
VideoHostingUtil.CreateDialogPrivacyAccount();
}
else
{
CreateDataLinkDialog();
}
}
public static void CreateDataLinkDialog()
{
SystemText systemText = Data.SystemText;
@@ -352,19 +33,6 @@ public class MyPageOtherButtons : UIBase
dialogBase.SetSize(DialogBase.Size.M);
}
public void OnBtnAccountConnect()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
if (SingletonMonoBehaviour<VideoHostingManager>.instance.IsRecording() || SingletonMonoBehaviour<VideoHostingManager>.instance.IsPublising())
{
VideoHostingUtil.CreateDialogPrivacyAccount();
}
else
{
CreateDialogAccountLink();
}
}
public static void CreateDialogAccountLink(Action close_callback = null)
{
SystemText systemText = Data.SystemText;
@@ -381,210 +49,4 @@ public class MyPageOtherButtons : UIBase
dialogBase.SetText(text);
dialogBase.SetSize(DialogBase.Size.M);
}
public void OnBtnContactSupport()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetSize(DialogBase.Size.M);
dialogBase.SetTitleLabel(Data.SystemText.Get("Con_Management_001_Title"));
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
GameObject gameObject = UnityEngine.Object.Instantiate(_dialogContactMenu);
gameObject.GetComponent<DialogContactMenu>().SetDialog(dialogBase);
dialogBase.SetObj(gameObject);
}
public void OnBtnNotification()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetTitleLabel(Data.SystemText.Get("OtherTop_0014"));
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
GameObject obj = UnityEngine.Object.Instantiate(_dialogNotificationMenu);
dialogBase.SetObj(obj);
}
public void OnBtnSwitchLanguage()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
SwitchLanguage.Create(isForceConfirmDialog: false, isTitle: false, delegate(bool isChangeLanguage)
{
if (isChangeLanguage)
{
Toolbox.SavedataManager.SetString(SavedataManager.LANGUAGE_CHANGE, "TRUE");
}
SoftwareReset.exec();
});
}
public void OnBtnReturnTitle()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
SystemText systemText = Data.SystemText;
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetTitleLabel(systemText.Get("OtherTop_0026"));
dialogBase.SetText(systemText.Get("OtherTop_0027"));
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
dialogBase.SetButtonText(systemText.Get("OtherTop_0028"));
dialogBase.onPushButton1 = delegate
{
SoftwareReset.exec();
};
}
public void OnBtnVideoHosting()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
ActivateVideoHosting();
}
private void ActivateVideoHosting()
{
if (SingletonMonoBehaviour<VideoHostingManager>.instance.IsVideoHostingSupported())
{
VideoHostingUtil.CreateVideoHostingSetting();
}
else
{
VideoHostingUtil.CreateDialogNotSupported();
}
}
public void OnBtnPortalSite()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
UIManager.ShowDialogUrl(Data.SystemText.Get("OtherTop_0030"), Data.SystemText.Get("URL_0002"));
}
public void OnBtnOffcialSite()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
SystemText systemText = Data.SystemText;
string text = "URL_0014";
text += "_steam";
UIManager.ShowDialogUrl(systemText.Get("OtherTop_0031"), systemText.Get(text));
}
public void OnBtnCodeInput()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
_dialogCodeInput = InputDialog.Create(16, 16);
_dialogCodeInput.InputAreaObjs.labels[2].text = Data.SystemText.Get("OtherCode_0009");
_dialogCodeInput.InputAreaObjs.labels[3].text = "";
_dialogCodeInput.SetTitleLabel(Data.SystemText.Get("OtherCode_0005"));
_dialogCodeInput.onPushButton1 = ReturnCodeInput;
_dialogCodeInput.SetButtonDisable(isEnableOK: true);
_codeInput = _dialogCodeInput.GetComponentInChildren<UIInput>();
_codeInput.onChange.Add(new EventDelegate(OnChangeCodeInput));
}
private void OnChangeCodeInput()
{
_dialogCodeInput.SetButtonDisable(_codeInput.value.Length < 16);
}
private void ReturnCodeInput()
{
string text = _dialogCodeInput.InputAreaObjs.labels[0].text;
MyPageCodeInputTask task = new MyPageCodeInputTask();
task.SetParameter(text);
StartCoroutine(Toolbox.NetworkManager.Connect(task, delegate(NetworkTask.ResultCode errorCode)
{
OnSuccessCodeInput(errorCode, task);
}));
}
private void OnSuccessCodeInput(NetworkTask.ResultCode errorcode, MyPageCodeInputTask inputTask)
{
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetTitleLabel(Data.SystemText.Get("OtherCode_0011"));
if (inputTask.IsComplete)
{
dialogBase.SetText(Data.SystemText.Get("OtherCode_0012"));
}
else
{
dialogBase.SetText(Data.SystemText.Get("OtherCode_0010"));
}
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
dialogBase.onPushButton1 = delegate
{
MailTopTask mailTopTask = GameMgr.GetIns().GetMailTopTask();
mailTopTask.SetParameter(isTutorial: false);
StartCoroutine(Toolbox.NetworkManager.Connect(mailTopTask, delegate
{
UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.Mail);
}));
};
}
public void OnBtnShutdown()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
Application.Quit();
}
public void OnBtnSignInOut()
{
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
SystemText text = Data.SystemText;
try
{
if (SocialServiceUtility.Instance.IsLoggedIn)
{
SocialServiceUtility.Instance.SignOut(delegate
{
_btnSignInOutLabel.text = text.Get("OtherTop_0035");
PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.SOCIAL_ACHIEVEMENT_SIGNIN, flag: false);
});
return;
}
StartCoroutine(SocialServiceUtility.Instance.SignIn(delegate(bool success)
{
if (success)
{
_btnSignInOutLabel.text = text.Get("OtherTop_0036");
PlayerPrefsWrapper.SetBool(PlayerPrefsWrapper.SOCIAL_ACHIEVEMENT_SIGNIN, flag: true);
}
}));
}
catch (Exception ex)
{
LocalLog.AccumulateTraceLog("サインイン・アウト処理失敗:" + ex);
}
}
private void _DisplayItemHistory(NetworkTask.ResultCode result)
{
DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
dialogBase.SetSize(DialogBase.Size.M);
dialogBase.SetTitleLabel(Data.SystemText.Get("Mail_0050"));
dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
UIManager.GetInstance().closeInSceneCenterLoading();
GameObject gameObject = UnityEngine.Object.Instantiate(_dialogRewardScroll);
dialogBase.SetObj(gameObject);
DialogRewardScroll component = gameObject.GetComponent<DialogRewardScroll>();
ResourceHandler resourceHandler = base.gameObject.AddMissingComponent<ResourceHandler>();
component.Handler = resourceHandler;
component.CurrentList = Data.ItemAcquireHistoryInfo.Histories;
component.resetScrollWrap();
dialogBase.OnClose = delegate
{
resourceHandler.UnloadAll();
UnityEngine.Object.Destroy(resourceHandler);
};
}
private void OnClickAdjustSetting()
{
AdjustSendSettingDialog.Create(_adjustSettingDialogPrefab).OnChange = delegate(bool enable)
{
AdjustSettingUpdateTask adjustSettingUpdateTask = new AdjustSettingUpdateTask();
adjustSettingUpdateTask.SetParameter(enable);
StartCoroutine(Toolbox.NetworkManager.Connect(adjustSettingUpdateTask, delegate
{
Data.Load.data._userConfig.SetArrowAdjustSend(enable);
}));
};
}
}