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

@@ -1,4 +1,8 @@
// AUTO-GENERATED no-op stubs (m1_stub_gen) from Shadowverse_Code_2026-05-23\Wizard.Battle.UI\BattleLogManager.cs
// TODO(engine-cleanup-pass2): 145 of 159 methods unrun in baseline
// Type: Wizard.Battle.UI.BattleLogManager
// See data_dumps/reports/engine-cleanup/live-methods.baseline.txt
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
@@ -11,86 +15,16 @@ public partial class BattleLogManager
public partial class CostCardLogInfo { }
public partial class CardLogInfo { }
public delegate void FuncSetup(BattleLogItem logItem);
private const int BATTLELOG_BLOCK_MAX = 30;
private const int SOLOMON_ID = 112341030;
private bool _isBattleLogOpen;
private BattleManagerBase _battleMgr;
private BattlePlayer _battlePlayer;
private WarPair _warBefore;
public BattleLogWindow _logWindow;
private BattleLogButton _logButton;
private GameObject _battleLogRoot;
private GameObject _battleLogButtonRoot;
public BattleLogItem _clickLogItem;
public BattleLogItem _clickSubLogItem;
private List<BattleLogItem> _logItemList;
private List<BattleLogItemSet> _logItemSetList;
private List<BattleLogItem> _pDestLogItemList;
private List<BattleLogItem> _eDestLogItemList;
private List<BattleLogItem> _pPlayCardLogItemList;
private List<BattleLogItem> _ePlayCardLogItemList;
private List<List<BattleLogItem>> _pDestLogItemListList;
private List<List<BattleLogItem>> _eDestLogItemListList;
private List<List<BattleLogItem>> _pPlayCardLogItemListList;
private List<List<BattleLogItem>> _ePlayCardLogItemListList;
private List<BattleLogItem> _deckSummonCardObjectList;
private List<CostCardLogInfo> _pDestroyedLogInfoList;
private List<CostCardLogInfo> _eDestroyedLogInfoList;
private List<CostCardLogInfo> _pPlayCardLogInfoList;
private List<CostCardLogInfo> _ePlayCardLogInfoList;
private Dictionary<int, int> _deckSummonCardIdList;
public List<BattleCardBase> PlayerFusionCard;
public List<BattleCardBase> EnemyFusionCard;
private List<GameObject> _pDestroyedCostFrameList;
private List<GameObject> _eDestroyedCostFrameList;
private List<GameObject> _pPlayCardCostFrameList;
private List<GameObject> _ePlayCardCostFrameList;
public List<BattleCardBase> PlayerPlayedCard;
public List<BattleCardBase> EnemyPlayedCard;
public List<BattleCardBase> PlayerDestroyedCard;
public List<BattleCardBase> EnemyDestroyedCard;
private int _pDestroyedMinCost;
private int _eDestroyedMinCost;
private int _pPlayCardMinCost;
private int _ePlayCardMinCost;
// PlayerFusionCard / EnemyFusionCard hoisted to BattleManagerBase as instance fields
// (2026-07-02) so concurrent battles don't alias a process-wide list — see
// BattleManagerBase.EnemyFusionCard.
private static BattleLogManager _instance;
private int _keyboardSelectLogNumber;
private BattleLogItem _selectBattleLog;
private BattleLogItemSet _oldClickLogItemSet;
private int _oldLogItemSetCount;
private List<BattleLogItem> _logCardList;
private const float CARD_FRAME_HIGHT = 48f;
private const float UI_SCREEN_HIGHT_HALF = 320f;
private const int DEFAULT_DESTROYED_COST = 99;
public const int MAX_COST_NUM = 30;
private bool _alertLayerEnable;
private int _alerOriginalLayer;
private CanNotTouchCardVfx _canNotTouchCardVfx;
private const int ZEUS_SUPREME_ID = 113041020;
private bool _isPlayerSkinEvolved;
private bool _isEnemySkinEvolved;
public bool IsOpen { get; set; }
public static BattleLogItem CreateLogItem(bool isSmall = false) => default!;
public static BattleLogItem CreateBuffLogItem(BattleCardBase card, BattleCardBase detailCard, BuffInfo buff, bool? isPlayer, bool useSmall, BattleLogItem.CardTextureOption textureOption = BattleLogItem.CardTextureOption.Null, int buffMomentCardId = -1, BossRushSpecialSkill specialSkillInfo = null) => default!;
public static MyRotationBonusItem CreateMyRotationBonusItem(BattlePlayerBase.MyRotationBonusCondition myRotationBonusCondition, bool isPlayer, bool needSeparator) => default!;
public static AvatarBattleTitleItem CreateAvatarBattleBonusTitleItem(string titleText, UIScrollView scrollView) => default!;
public static AvatarBattleTitleItem CreateAvatarBattleBuffTitleItem(string titleText, UIScrollView scrollView) => default!;
public static AvatarBattleBonusItem CreateAvatarBattleBonusItem(BattlePlayerBase.AvatarBattleDescInfo skillDescInfo, UIScrollView scrollView, bool isNeedSeparator, BattleCardBase targetCard) => default!;
public static AvatarBattlePassiveBonusItem CreateAvatarBattlePassiveBonusItem(BattlePlayerBase.AvatarBattleDescInfo skillDescInfo, BattleCardBase targetCard, UIScrollView scrollView) => default!;
public static BattleLogItem CreateBossRushPlayerSpecialSkillLogItem(BattleCardBase card, BossRushSpecialSkill bossRushSpecialSkill) => default!;
public static BossRushEnemySpecialSkillItem CreateEnemyBossRushSpecialSkillLogItem(BattleCardBase card, BossRushSpecialSkill bossRushSpecialSkill) => default!;
public static void DestroyLogItem(BattleLogItem logItem) { }
public static BattleLogItemSet CreateLogItemSet() => default!;
public static void DestroyLogItemSet(BattleLogItemSet logItemSet) { }
public static BattleLogManager GetInstance() => _instance ??= new BattleLogManager(); // HEADLESS-FIX (M9): non-null singleton so the draw's unguarded BattleLog tail (UpdateFusionedCardSkillDrewCard, and the IsBattleLog AddLogSkillDrawCard calls) no-ops instead of NRE on a null instance
private BattleLogManager() { }
public void SetUp(Transform parent, BattleManagerBase battleMgr, OperateMgr operateMgr, BattlePlayer battlePlayer) { }
public void Clear() { }
public void ClearDestroyedCardList(bool isPlayer) { }
public void ClearPlayedCardList(bool isPlayer) { }
private void _SetActiveWindow(bool isActive, BattleLogWindow.BattleLogType logType = BattleLogWindow.BattleLogType.Battle, bool isPlayer = true) { }
public void SetActiveShowButton(bool isActive) { }
public void ShowLog(BattleLogWindow.BattleLogType logType, bool isPlayer = true) { }
public void HideLog() { }
public void BeginLogBlockEvolution(BattleCardBase card) { }
public VfxBase EndLogBlockEvolution() => global::Wizard.Battle.View.Vfx.NullVfx.GetInstance();
@@ -104,50 +38,14 @@ public partial class BattleLogManager
public VfxBase SetupWarActionLog() => global::Wizard.Battle.View.Vfx.NullVfx.GetInstance();
public VfxBase BeginLogBlockWar(BattleCardBase attackCard, BattleCardBase attackedCard) => global::Wizard.Battle.View.Vfx.NullVfx.GetInstance();
public VfxBase EndLogBlockWar(BattleCardBase attackCard, BattleCardBase attackedCard, bool needAttack) => global::Wizard.Battle.View.Vfx.NullVfx.GetInstance();
private LogType GetTimingLogType(SkillBase skill) => default!;
private void _AddLogSkillTiming(SkillBase skill, BattleLogItem.CardTextureOption textureOption = BattleLogItem.CardTextureOption.Null) { }
private void _AddLogSkillTiming(BattleCardBase ownerCard, LogType logType, BattleLogItem.CardTextureOption textureOption = BattleLogItem.CardTextureOption.Null) { }
public void AddNecromanceIcon(SkillBase skill, BattleCardBase card, bool isSpell) { }
private BattleLogItem _AddLogCommonOne(BattleCardBase card, FuncSetup funcSetup, bool isOwner = false, BattleLogItem.CardTextureOption textureOption = BattleLogItem.CardTextureOption.Null, List<NewReplayBattleMgr.BattleLogTextureInfo> battleLogTextureInfo = null) => default!;
private void _AddLogCommon(List<BattleCardBase> cards, FuncSetup funcSetup, bool isOwner = false, BattleLogItem.CardTextureOption textureOption = BattleLogItem.CardTextureOption.Null) { }
public BattleLogItem AddLogCommonOneAndSetInner(BattleCardBase card, FuncSetup funcSetup, BattleLogItem.CardTextureOption textureOption, List<NewReplayBattleMgr.BattleLogTextureInfo> battleLogTextureInfo) => default!;
public void RemoveAllBattleLogSet() { }
public void ParentLogItemToGrid() { }
private int _SetupLogItemSet() => default!;
private int GetMinCost(BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
private void SetMinCost(BattleLogWindow.BattleLogType type, bool isPlayer, int value) { }
private List<GameObject> GetCostFrameList(BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
private List<CostCardLogInfo> GetCostCardLogInfoList(BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
private List<List<BattleLogItem>> GetLogListList(BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
private List<BattleLogItem> GetLogList(BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
private GameObject GetLogObject(BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
private UILabel GetEmptyTextLabel(BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
public static Dictionary<BattleCardBase, int> GetCardCountsByCardId(List<BattleCardBase> cards) => default!;
public static int CompareCardLogInfo(BattleCardBase cardA, BattleCardBase cardB) => default!;
public static int CompareCardLogInfo(CardLogInfo logInfoA, CardLogInfo logInfoB) => default!;
private string GetNameIndex(int cost, int index) => default!;
private void _AddDestLogCommonOne(BattleCardBase card, FuncSetup funcSetup, BattleLogWindow.BattleLogType type, bool isPlayer, List<NewReplayBattleMgr.BattleLogTextureInfo> battleLogTextureInfo) { }
private void _ParentDestLogItemToGrid(BattleLogWindow.BattleLogType type, bool isPlayer) { }
private void _SetupLogDestItemList(BattleLogWindow.BattleLogType type, bool isPlayer) { }
private void MakeAndHideCostFrameList(BattleLogWindow.BattleLogType type, bool isPlayer) { }
public void SetupCostFrame() { }
public void AddLogDestFollower(BattleLogWindow.BattleLogType type, BattleCardBase card, List<NewReplayBattleMgr.BattleLogTextureInfo> battleLogTextureInfo = null) { }
private int GetCardIndex(int cost, int id, BattleLogWindow.BattleLogType type, bool isPlayer) => default!;
public void AddLogCost(int cost, BattleLogWindow.BattleLogType type, bool isPlayer) { }
public void EnableButton() { }
public void DisableButton() { }
private bool _IsAddLogBerserk(BattleCardBase beforeDamage, BattleCardBase afterDamage) => default!;
private bool _IsAddLogAwake(BattleCardBase card, int ppTotalPrev) => default!;
private bool _IsAddLogWar(BattleCardBase attackCard, BattleCardBase attackedCard) => default!;
private BattleLogItem _CreateAttack(bool isCounter, BattleCardBase beforeAttackFrom, BattleCardBase afterAttackFrom, bool isDamageDraw, bool isDrainBattle) => default!;
public VfxBase AddLogWar(BattleCardBase attackCard, BattleCardBase attackedCard) => global::Wizard.Battle.View.Vfx.NullVfx.GetInstance();
public void AddLogEvolution(BattleCardBase card) { }
public void AddLogFusion(BattleCardBase card, List<BattleCardBase> ingrediens) { }
public void AddLogSkillGetOn(BattleCardBase card, List<BattleCardBase> ingrediens) { }
public void AddLogSkillGetOff(SkillBase skill, List<BattleCardBase> ingrediens) { }
public BattleLogItem AddLogTurn(bool isSelfTurn, int turn = -1) => default!;
public void AddLogMulliganChanged(BattlePlayerBase player, int changedNum) { }
private BattleLogItem GetSameTypeLogItem(BattleCardBase card, LogType logType) => default!;
public void AddLogSkillDrawCard(List<BattleCardBase> drawCards, SkillBase skill, bool isOpen, bool isPlayerDraw, bool isOverDraw) { }
public void AddLogSkillDrawToken(List<BattleCardBase> drawCards, SkillBase skill, bool isOpen, bool isOverDraw = false) { }
public void AddLogOverDrawCards(List<BattleCardBase> overDrawCards) { }
@@ -184,11 +82,9 @@ public partial class BattleLogManager
public void AddLogSkillHeal(List<BattleCardBase> beforeHealCards, List<BattleCardBase.HealResult> healResults) { }
public void AddLogHeal(BattleCardBase beforeHealCard, int healAmount) { }
public void AddLogSkillDamage(BattleCardBase beforeDamage, BattleCardBase afterDamage, BattleCardBase beforeRefrection, BattleCardBase afterRefrection, SkillBase skill) { }
private void _AddLogDamage(BattleCardBase beforeDamage, BattleCardBase afterDamage, SkillBase skill) { }
public void AddLogSkillDeath(List<BattleCardBase> deathCards, SkillBase skill) { }
public void AddLogSkillDeath(List<BattleCardBase> deathCards) { }
public void AddLogDeath(BattleCardBase deathCard) { }
private void _AddLogDeath(List<BattleCardBase> deathCards) { }
public void AddLogSkillEvolution(List<BattleCardBase> evolveCards, SkillBase skill) { }
public void AddLogSkillMetamorphose(List<Skill_metamorphose.MetamorphoseCardPair> pairList, SkillBase skill, bool isTargetInOpponentHand = false, bool isFusion = false) { }
public void AddLogSkillUnite(Skill_unite.UniteCardPair pair, SkillBase skill) { }
@@ -199,34 +95,17 @@ public partial class BattleLogManager
public void AddLogSkillChangeClan(List<BattleCardBase> cards, CardBasePrm.ClanType newClan, SkillBase skill, bool isTargetInOpponentHand = false) { }
public void AddLogSkillChangeTribe(List<BattleCardBase> cards, List<CardBasePrm.TribeType> newTribe, SkillBase skill, bool isTargetInOpponentHand = false) { }
public void AddTokenDrawModifier(List<BattleCardBase> targetCards, SkillBase skill) { }
public static string GetTargetCostConditionText(SkillBase skill) => default!;
public void AddLogSkillChangePlayCount(BattleCardBase card, int count, SkillBase skill) { }
public void AddLogSkillShortageDeckWin(List<BattleCardBase> cards, SkillBase skill) { }
public void AddLogCostChange(List<BattleCardBase> cards, SkillBase skill, int cost, bool isSetCost, bool isTargetInOpponentHand, List<int> setCostDifferenceList) { }
public void AddLogOpenCard(BattleCardBase card) { }
public void AddLogOpenDrawCard(BattleCardBase card, SkillBase skill) { }
public void AddLogExclusionTargetList(List<BattleCardBase> cards, SkillBase skill) { }
public void InsertExclusionTargetListLog(SkillBase skill) { }
private static bool IsSameSkillTiming(LogType logA, LogType logB, bool isSpell) => default!;
private bool _CheckLastAddedSkillOwner(BattleCardBase card, LogType timingLogType) => default!;
private bool ExistSameCardLog(BattleCardBase card, LogType timingLogType) => default!;
public void AddLogSkillUsePp(SkillBase skill, BattleCardBase card, int usePp) { }
public void AddLogGiveWhiteRitualStack(int num, BattleCardBase targetCard, SkillBase skill) { }
public void AddLogDepriveWhiteRitualStack(int num, BattleCardBase targetCard, SkillBase skill) { }
public void UpdateSkillTiming(BattleCardBase card, LogType oldType, LogType newType) { }
private bool UpdateDamageAmount(BattleCardBase card, int amount, SkillBase skill, LogType logType) => default!;
private bool UpdateSummonCount(BattleCardBase card, int summonCount, SkillBase skill, bool isPlayerSide) => default!;
public void KeyboardSelectNext(int number) { }
public void KeyboardSelectBack(int number) { }
public void KeyboardSelectNumber(int number) { }
public void KeyboardResetSelect() { }
public void KeyboardUpdateLogList() { }
public void KeyboardUpdateScrollView() { }
public static int ConvertPremiumIdToNormalId(int cardId) => default!;
public void AddFusionIngredients(BattleCardBase fusionCard, bool isCreateClone) { }
public void ResetFusionIngredients(bool isPlayer) { }
public int GetFusionOrder(BattleCardBase a, BattleCardBase b) => default!;
public void UpdateFusionedCardSkillDrewCard(BattleCardBase fusionCard) { }
private void ReplacePlayerBattleLog(bool isPlayer) { }
}
}