Files
SVSimServer/SVSim.BattleEngine/Engine/Wizard/BaseSelectBuyMeansDialog.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

178 lines
5.5 KiB
C#

using System;
using Cute;
using UnityEngine;
namespace Wizard;
public abstract class BaseSelectBuyMeansDialog : MonoBehaviour
{
private static readonly Vector3 BUY_OBJECTS_CENTER_POS = new Vector3(0f, -230f);
private static readonly Vector3 BUY_OBJECTS_LEFT_POS = new Vector3(-140f, -230f);
private static readonly Vector3 BUY_OBJECTS_RIGHT_POS = new Vector3(140f, -230f);
[SerializeField]
private UILabel _labelDescription;
[SerializeField]
private UIButton m_buttonRupy;
[SerializeField]
private UIButton m_buttonCrystal;
[SerializeField]
private UIButton _ticketButton;
[SerializeField]
private GameObject _objectUnderLine;
[SerializeField]
private UILabel m_labelRupyHaveNum;
[SerializeField]
private UILabel m_labelCrystalHaveNum;
[SerializeField]
private UILabel _labelTicketHaveNum;
[SerializeField]
private UILabel m_labelRupyCostNum;
[SerializeField]
private UILabel m_labelCrystalCostNum;
[SerializeField]
private UILabel _labelTicketCostNum;
[SerializeField]
private UILabel m_labelRupyBtnBuy;
[SerializeField]
private UILabel m_labelCrystalBtnBuy;
[SerializeField]
private UILabel _labelTicketButtonBuy;
[SerializeField]
private UITexture _ticketIconTexture;
private DialogBase m_dialog;
protected void SetDescriptionLabel(string text)
{
_labelDescription.text = text;
}
protected string GetDescriptionText(ShopCommonSaleInfo info)
{
return Data.SystemText.Get("Shop_0047", info.name.Replace("\n", ""));
}
protected void _Init(ShopCommonSaleInfo info, DialogBase dialog, Action onPushBuyCrystalBtnCallBack, Action onPushBuyRupyBtnCallBack, Action onPushTicketButtonCallBack)
{
SystemText systemText = Data.SystemText;
m_dialog = dialog;
_labelDescription.text = GetDescriptionText(info);
if (_ticketButton != null)
{
_ticketButton.gameObject.SetActive(value: false);
}
if (info.isFree)
{
m_buttonCrystal.gameObject.SetActive(value: false);
m_buttonRupy.gameObject.SetActive(value: false);
UILabel labelDescription = _labelDescription;
labelDescription.text = labelDescription.text + "\n" + systemText.Get("Shop_0103");
_objectUnderLine.SetActive(value: false);
}
else if (info.costCrystal.HasValue && info.costRupy.HasValue)
{
m_buttonCrystal.gameObject.SetActive(value: true);
m_buttonCrystal.gameObject.transform.localPosition = BUY_OBJECTS_RIGHT_POS;
_SetCrystalBuyObjects(info.costCrystal.Value, onPushBuyCrystalBtnCallBack);
m_buttonRupy.gameObject.SetActive(value: true);
m_buttonRupy.gameObject.transform.localPosition = BUY_OBJECTS_LEFT_POS;
_SetRupyBuyObjects(info.costRupy.Value, onPushBuyRupyBtnCallBack);
UILabel labelDescription2 = _labelDescription;
labelDescription2.text = labelDescription2.text + "\n" + systemText.Get("Shop_0107");
}
else if (info.costCrystal.HasValue)
{
m_buttonCrystal.gameObject.SetActive(value: true);
m_buttonCrystal.gameObject.transform.localPosition = BUY_OBJECTS_CENTER_POS;
_SetCrystalBuyObjects(info.costCrystal.Value, onPushBuyCrystalBtnCallBack);
m_buttonRupy.gameObject.SetActive(value: false);
}
else if (info.costTicket.HasValue)
{
m_buttonRupy.gameObject.SetActive(value: false);
m_buttonCrystal.gameObject.SetActive(value: false);
_ticketButton.gameObject.SetActive(value: true);
_ticketButton.gameObject.transform.localPosition = BUY_OBJECTS_CENTER_POS;
if (_ticketIconTexture != null && info.costTicketItemId.HasValue)
{
_ticketIconTexture.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(ShopCommonUtility.GetTicketIconPath(info.costTicketItemId.Value.ToString(), isFetch: true));
}
SetTicketButtonObjects(info, onPushTicketButtonCallBack);
}
else
{
m_buttonRupy.gameObject.SetActive(value: true);
m_buttonRupy.gameObject.transform.localPosition = BUY_OBJECTS_CENTER_POS;
_SetRupyBuyObjects(info.costRupy.Value, onPushBuyRupyBtnCallBack);
m_buttonCrystal.gameObject.SetActive(value: false);
}
}
private void SetTicketButtonObjects(ShopCommonSaleInfo info, Action onPushTicketButtonCallBack)
{
_labelTicketHaveNum.text = info.haveTicketNum.Value.ToString();
_labelTicketCostNum.text = info.costTicket.Value.ToString();
ShopCommonUtility.SetButtonLabelStyle(_ticketButton, _labelTicketButtonBuy);
_ticketButton.onClick.Clear();
_ticketButton.onClick.Add(new EventDelegate(delegate
{
onPushTicketButtonCallBack();
m_dialog.CloseWithoutSelect();
}));
}
private void _SetCrystalBuyObjects(int costCrystal, Action onPushButtonCrystal)
{
m_labelCrystalHaveNum.text = PlayerStaticData.UserCrystalCount.ToString();
m_labelCrystalCostNum.text = costCrystal.ToString();
ShopCommonUtility.SetButtonLabelStyle(m_buttonCrystal, m_labelCrystalBtnBuy);
m_buttonCrystal.onClick.Clear();
m_buttonCrystal.onClick.Add(new EventDelegate(delegate
{
onPushButtonCrystal();
m_dialog.CloseWithoutSelect();
}));
}
private void _SetRupyBuyObjects(int costRupy, Action onPushButtonRupy)
{
m_labelRupyHaveNum.text = PlayerStaticData.UserRupyCount.ToString();
m_labelRupyCostNum.text = costRupy.ToString();
if (PlayerStaticData.UserRupyCount >= costRupy)
{
m_buttonRupy.isEnabled = true;
}
else
{
m_buttonRupy.isEnabled = false;
}
ShopCommonUtility.SetButtonLabelStyle(m_buttonRupy, m_labelRupyBtnBuy);
m_buttonRupy.onClick.Clear();
m_buttonRupy.onClick.Add(new EventDelegate(delegate
{
onPushButtonRupy();
m_dialog.CloseWithoutSelect();
}));
}
}