Files
SVSimServer/SVSim.BattleEngine/Engine/RoomInviteReceiveDialog.cs
gamer147 2d9a6eea4b 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>
2026-07-03 19:18:54 -04:00

256 lines
7.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.ErrorDialog;
using Wizard.RoomMatch;
using Wizard.UIFriend;
public class RoomInviteReceiveDialog : MonoBehaviour
{
[SerializeField]
protected UIWrapContent WrapContents;
[SerializeField]
protected WrapContentsScrollBarSize WrapScrollbarSize;
[SerializeField]
protected GameObject ScrollViewObject;
[SerializeField]
protected GameObject ScrollBarObject;
[SerializeField]
protected GameObject ScrollAreaObject;
protected List<Friend.PlayerData> _playerList;
protected Dictionary<int, List<string>> _loadQueueDict = new Dictionary<int, List<string>>();
protected List<string> _loadBookingList = new List<string>();
protected List<string> _loadedList = new List<string>();
protected LoadQueue _loadQueue = new LoadQueue();
protected DialogBase _dialog;
protected bool _isJoinRoom;
public MyPageMenu MyPageClass { get; set; }
public void SetFriendList()
{
_playerList = new List<Friend.PlayerData>();
Friend.PlayerData item = default(Friend.PlayerData);
foreach (UserFriend friend in Wizard.Data.FriendInfo.data.friendList)
{
item.Copy(friend);
_playerList.Add(item);
}
StartCoroutine(LoadCoroutine());
}
private IEnumerator LoadCoroutine()
{
if (_playerList.Count == 0)
{
_dialog = UIManager.GetInstance().CreateDialogClose();
_dialog.SetTitleLabel(Wizard.Data.SystemText.Get("RoomBattle_0068"));
_dialog.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
_dialog.SetText(Wizard.Data.SystemText.Get("RoomBattle_0067"));
ReturnTopFromError(_playerList.Count);
}
else
{
_loadedList.Clear();
_loadBookingList.Clear();
_loadQueueDict.Clear();
List<string> list = new List<string>();
for (int i = 0; i < _playerList.Count; i++)
{
string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(_playerList[i].EmblemId.ToString(), ResourcesManager.AssetLoadPathType.Emblem_S);
string assetTypePath2 = Toolbox.ResourcesManager.GetAssetTypePath(_playerList[i].Rank.ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_S);
string text = (string.IsNullOrEmpty(_playerList[i].Country) ? null : Toolbox.ResourcesManager.GetAssetTypePath(_playerList[i].Country, ResourcesManager.AssetLoadPathType.Country_S));
List<string> list2 = new List<string>();
if (!_loadedList.Contains(assetTypePath) && !list.Contains(assetTypePath))
{
list.Add(assetTypePath);
list2.Add(assetTypePath);
}
foreach (string degreeResource in DegreeHelper.GetDegreeResourceList(_playerList[i].DegreeId, DegreeHelper.DegreeType.SMALL, isFetch: false))
{
if (!_loadedList.Contains(degreeResource) && !list.Contains(degreeResource))
{
list.Add(degreeResource);
list2.Add(degreeResource);
}
}
if (!_loadedList.Contains(assetTypePath2) && !list.Contains(assetTypePath2))
{
list.Add(assetTypePath2);
list2.Add(assetTypePath2);
}
if (text != null && !_loadedList.Contains(text) && !list.Contains(text))
{
list.Add(text);
list2.Add(text);
}
if (6 > i)
{
_loadBookingList.AddRange(list2);
continue;
}
_loadQueueDict.Add(i, list2);
LoadQueue.Callback onEnd = delegate(string id)
{
_loadedList.AddRange(_loadQueueDict[int.Parse(id)]);
};
_loadQueue.AddToLast(i.ToString(), list2, null, onEnd);
}
bool loadEndFlg = false;
StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(_loadBookingList, delegate
{
loadEndFlg = true;
}));
while (!loadEndFlg)
{
yield return null;
}
_loadedList.AddRange(_loadBookingList);
_loadQueue.StartLoad();
_dialog = UIManager.GetInstance().CreateDialogClose();
_dialog.SetTitleLabel(Wizard.Data.SystemText.Get("RoomBattle_0069"));
_dialog.SetObj(base.gameObject);
_dialog.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
_dialog.SetSize(DialogBase.Size.M);
_dialog.OnClose = delegate
{
UIManager.GetInstance().StartCoroutine(InviteDialogClose());
};
Init();
}
UIManager.GetInstance().closeInSceneCenterLoading();
}
protected IEnumerator InviteDialogClose()
{
if (!_isJoinRoom)
{
UIManager.GetInstance().createInSceneCenterLoading();
}
_loadQueue.Clear();
while (_loadQueue.IsClearing)
{
yield return null;
}
Toolbox.ResourcesManager.RemoveAssetGroup(_loadedList);
if (!_isJoinRoom)
{
UIManager.GetInstance().closeInSceneCenterLoading();
}
}
public void Init()
{
WrapContents.onInitializeItem = _OnInitializeItem;
WrapContents.maxIndex = 0;
ScrollBarObject.GetComponent<UIScrollBarWrapContent>().m_WrapContents = WrapContents;
WrapContents.minIndex = -(_playerList.Count - 1);
WrapScrollbarSize.ContentUpdate();
WrapContents.SortBasedOnScrollMovement();
UIPanel component = ScrollViewObject.GetComponent<UIPanel>();
int count = _playerList.Count;
if (component.height > (float)(count * WrapContents.itemSize))
{
ScrollBarObject.SetActive(value: false);
ScrollAreaObject.SetActive(value: false);
ScrollViewObject.GetComponent<UIScrollView>().ResetPosition();
}
else
{
ScrollBarObject.SetActive(value: true);
ScrollAreaObject.SetActive(value: true);
}
ScrollViewObject.GetComponent<UIScrollView>().ResetPosition();
ScrollBarObject.GetComponent<UIScrollBar>().value = 0f;
}
protected void _OnInitializeItem(GameObject go, int wrapIndex, int realIndex)
{
int num = realIndex * -1;
go.name = num.ToString();
Transform[] componentsInChildren = go.GetComponentsInChildren<Transform>(includeInactive: true);
Transform[] array;
if (num >= _playerList.Count || num < 0)
{
array = componentsInChildren;
for (int i = 0; i < array.Length; i++)
{
array[i].gameObject.SetActive(value: false);
}
return;
}
array = componentsInChildren;
for (int i = 0; i < array.Length; i++)
{
array[i].gameObject.SetActive(value: true);
}
go.transform.GetComponent<RoomInviteFriendColum>().SetPlayerData(_playerList[num], _loadedList);
EventDelegate eventDelegate = new EventDelegate(this, "RoomJoin");
eventDelegate.parameters[0].value = num;
RoomInviteFriendColum component = go.GetComponent<RoomInviteFriendColum>();
component.ButtonObject.onClick.Clear();
component.ButtonObject.onClick.Add(eventDelegate);
if (num + 1 == _playerList.Count)
{
component.UnderLineObject.SetActive(value: false);
}
else
{
component.UnderLineObject.SetActive(value: true);
}
}
protected void RoomJoin(int inPlayerIndex)
{
InviteAcceptTask inviteAcceptTask = new InviteAcceptTask();
inviteAcceptTask.SetParameter(_playerList[inPlayerIndex].ViewerId);
inviteAcceptTask.SkipAllCuteResultCodeCheckErrorPopup();
StartCoroutine(Toolbox.NetworkManager.Connect(inviteAcceptTask, AcceptSuccess, null, ErrorDialog));
}
private void AcceptSuccess(NetworkTask.ResultCode inResultCode)
{
if (!(_dialog == null))
{
_dialog.Close();
_isJoinRoom = true;
RoomConnectController.InitializeParameter param = new RoomConnectController.InitializeParameter(RoomConnectController.PositionMode.VISITOR, new BattleParameter(NetworkDefine.ServerBattleType.OpenRoom, Format.Max, TwoPickFormat.None, Wizard.Data.InviteFriendBattle.BattleParameterInstance.Rule, isOpenDeckRoom: false), Wizard.Data.InviteFriendBattle.RoomId);
UIManager.GetInstance().StartCoroutine(MyPageMenu.Instance.BattleMenu.JoinRoom(param, isInvite: true));
}
}
protected void ErrorDialog(int inErrorNo)
{
ReturnTopFromError(Wizard.Data.Load.data._receiveInviteCount);
_dialog.Close();
Dialog.Create(inErrorNo);
}
protected void ReturnTopFromError(int inInviteCount)
{
if (inInviteCount <= 1)
{
InviteReset();
}
}
protected void InviteReset()
{
Object.Destroy(base.gameObject);
}
}