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

@@ -9,219 +9,16 @@ public partial class BattleLogItem
{
public enum CardTextureOption
{
Null,
ForceNormal,
ForceEvolution,
DestroyedFollower
}
Null}
private enum FrameType
{
Unit,
Field,
Spell,
Class
}
Spell }
private enum DescStyle
{
Normal,
TurnSelf,
TurnOpponent,
Max
}
Normal }
private delegate string FuncDescText();
private static readonly string[] FRAMESPRITE_SELF;
private static readonly string[] FRAMESPRITE_OPPONENT;
private static readonly string[] FRAMESPRITE_SELECT;
private static readonly Color[] DESC_COL;
private static readonly UIWidget.Pivot[] DESC_PIVOT;
public const string BATTLE_LOG_ICON_PLAY = "battle_log_icon_play";
public const string BATTLE_LOG_ICON_ENHANCE = "battle_log_icon_enhance";
public const string BATTLE_LOG_ICON_ACCELERATE = "battle_log_icon_accelerate";
public const string BATTLE_LOG_ICON_FIGHT = "battle_log_icon_fight";
public const string BATTLE_LOG_ICON_DESTROY = "battle_log_icon_destroy";
public const string BATTLE_LOG_ICON_NECROMANCE = "battle_log_icon_necromance";
public const string BATTLE_LOG_ICON_DRAW = "battle_log_icon_draw";
public const string BATTLE_LOG_ICON_OVERDRAW = "battle_log_icon_overdraw";
public const string BATTLE_LOG_ICON_SUMMON = "battle_log_icon_summon";
public const string BATTLE_LOG_ICON_BUFF = "battle_log_icon_buff";
public const string BATTLE_LOG_ICON_DEBUFF = "battle_log_icon_debuff";
public const string BATTLE_LOG_ICON_BANISH = "battle_log_icon_banish";
public static readonly Color DAMAGE_LABEL_COLOR;
public static readonly Color HEAL_LABEL_COLOR;
private static readonly Color32 CARD_COLOR_GREY;
public static readonly float LOG_ITEM_HEIGHT;
private const float FRAME_POS_X_LEFT = -30f;
private const float FRAME_POS_X_RIGHT = 30f;
private const float FRAME_POS_X_CENTER = 0f;
private const float NO_FRAME_TEXT_OFFSET = -8f;
private const float DESC_LABEL_CENTER_POSITION_X = 42f;
private UISprite _frame;
private UIButton _frameButton;
private UISprite _selectCursor;
private TweenAlpha _selectTween;
private UISprite _separator;
private UITexture _cardTexture;
private UILabel _desc;
private UILabel _num;
private Transform _locator;
private UILabel _rightText;
private UISprite _leftIcon;
private UISprite _rightIcon;
private Transform _fightIcon;
private GameObject _dammyFrame;
private bool isBuff;
private BattlePlayer _battlePlayer;
private BattleManagerBase _battleMgr;
private BattleLogManager _battleLogMgr;
private BattleCardBase _card;
private BattleCardBase _detailCard;
private int _buffMomentCardId;
private LogType _logType;
private bool _isOwner;
private SkillBase _logSkill;
private CardTextureOption _textureOption;
private bool _isCopiedBuff;
public BuffInfo Buff;
public int Turn { get; set; }
public bool IsPlayerSideTurn { get; set; }
public string DivergenceId { get; set; }
public BossRushSpecialSkill BossRushSpecialSkill { get; set; }
public bool IsPlayer { get; set; }
public void SetBuff(BuffInfo buff) { }
public bool IsCopiedBuff() => default!;
public static void ClearHeaderTextureCache() { }
public static int GetHeaderTextureCacheNum() => default!;
public CardTextureOption GetTextureOption() => default!;
private void Start() { }
public bool IsOwner() => default!;
public BattleCardBase GetCard() => default!;
public BattleCardBase GetDetailCard() => default!;
public int GetBuffMomentCardId() => default!;
public SkillBase GetLogSkill() => default!;
public void SetLogSkill(SkillBase skill) { }
public void SetDivergenceId(string divergenceId) { }
public Transform GetLocator() => default!;
public LogType GetLogType() => default!;
public float GetPosX() => default!;
public GameObject GetSeparator() => default!;
private int GetTextureId() => default!;
public void Setup(BattleCardBase card, BattlePlayer battlePlayer, BattleManagerBase battleMgr, BattleLogManager battleLogMng, bool isOwner, CardTextureOption textureOption = CardTextureOption.Null, BattleCardBase detailCard = null, bool? isPlayer = null, BuffInfo buff = null, int buffMomentCardId = -1, BossRushSpecialSkill specialSkillInfo = null, List<NewReplayBattleMgr.BattleLogTextureInfo> battleLogTextureInfo = null, bool isBattleInfo = false) { }
public void SetupOnReplay(bool isPlayerSideTurn, int turn) { }
public void ReplaceDeckSummonLogCard(BattleCardBase deckSummonCard) { }
public void ReplaceDeckSummonLogCard(List<BattleCardBase> deckSummonCards) { }
public void _SetupCardTexture(BattleCardBase card, CardTextureOption textureOption, int buffMomentCardId, List<NewReplayBattleMgr.BattleLogTextureInfo> battleLogTextureInfo) { }
private void _SetupFrame(BattleCardBase card, bool? isPlayer = null, bool isOpponentAllHandSpellCostChange = false, BossRushSpecialSkill specialSkillInfo = null) { }
private void _SetupFrameSelect(BattleCardBase card) { }
private string _GetFrameSpriteName(BattleCardBase card, string[] spriteNameList, bool isOpponentAllHandSpellCostChange = false, BossRushSpecialSkill specialSkillInfo = null) => default!;
private void _SetupDescStyle(DescStyle style) { }
private void _SetupDescColor(DescStyle style) { }
public void SetTurn(bool isSelfTurn, int turn = -1) { }
public void SetCost(int cost, bool isPlayer) { }
private void _SetInner(LogType logType, FuncDescText funcText, string rightValueText = "", int mulliganCount = -1) { }
private void _SetInnerOnSkillTiming(LogType logType, SkillBase skill) { }
private void SetInnerOnSkillTiming(LogType logType) { }
public void UpdateLogType(LogType logType) { }
public void AddNecromanceLog() { }
private void _SetInnerOnDamage(LogType logType, BattleCardBase afterCard, int damageNum, bool isDrainBattle = false) { }
private void SetInnerOnDamage(LogType logType) { }
private void _SetInnerOnHeal(LogType logType, int healNum = -1, bool isDrain = false) { }
private void SetInnerOnHeal(LogType logType) { }
private void _SetInnerOnSkillTarget(LogType logType, bool isMinus = false, string logText = null, string rightValueText = null, int cardWithCount = -1, int[] randomArray = null, bool isDeadInNewReplay = false, bool isNewReplay = false) { }
public void AddUpRightValue(int addValue, string zeroSign = null) { }
public void ChangeDamageLogToDestroy() { }
public void AddDamageAmount(int damage, bool isDamage) { }
public void AddSummonCount(int summonCount) { }
private void CallOnCreateBattleLog(string rightValueText, NewReplayBattleMgr.BattleLogItemType logItemType, bool isMinus = false, bool isNecromance = false, int cardWithCount = -1, int[] randomArray = null, bool isDrain = false, bool isDrainBattle = false, bool isDeadByDamage = false, int mulliganCount = -1) { }
private void _SetInnerCard(LogType logType) { }
private void _SetInnerCard(LogType logType, int num) { }
public void SetBattleLogCardList(int num = 1) { }
public void SetDeckSummonCardList(int num = 1) { }
public void SetFusionInfoList() { }
public void SetFusionIngredientInfoList() { }
public void UpdateBattleLogCardCount(int num) { }
public void SetMulliganChanged(int changedNum) { }
public void SetPlay(LogType logType = LogType.Play) { }
public void SetSummon(int count, SkillBase skill) { }
public void SetAttack(BattleCardBase attackerAfter, bool isDamageDraw, bool isDrainBattle) { }
public void SetAttackCounter(BattleCardBase attackerAfter, bool isDrainBattle) { }
public void SetDrawCard(List<BattleCardBase> drawCards, bool isOverDraw = false) { }
public void SetOverDraw(bool isTurnStartDraw) { }
public void SetOpenDrawCard(SkillBase skill) { }
public void SetOpenCard() { }
public void SetDrawToken(int count, bool isOverDraw = false) { }
public void SetReturnCard(SkillBase skill) { }
public void SetDiscardCardNum(List<BattleCardBase> discardCards, SkillBase skill) { }
public void SetDiscardCard(SkillBase skill) { }
public void SetBanishHandCardNum(List<BattleCardBase> discardCards, SkillBase skill) { }
public void SetBanishDeckCardNum(List<BattleCardBase> discardCards, SkillBase skill) { }
public void SetBanishDeckCard(SkillBase skill) { }
public void SetBanishHandCard(SkillBase skill) { }
public void SetChangeCemetery(int num, SkillBase skill) { }
public void SetClearDestroyedCardList(SkillBase skill) { }
public void SetClearSummonedCardList(SkillBase skill) { }
public void SetChangeChantCount(int num, SkillBase skill) { }
public void SetChangeWhiteRitualStack(int num, SkillBase skill, bool isDebuffSkill) { }
public void SetChangePP(int num, bool isTotal, SkillBase skill) { }
public void SetEP(int ep, SkillBase skill) { }
public void SetEvolution() { }
public void SetEvolutionBySkill(SkillBase skill) { }
public void SetFusion(int materialCount) { }
public void SetFusionIngredient() { }
public void SetGeton() { }
public void SetGetonIngredient() { }
public void SetGetoffIngredient() { }
public void SetCantAttack(CantAttackType type, SkillBase skill) { }
public void SetAttackCountRecovery(SkillBase skill) { }
public void SetChangeDeck(SkillBase skill) { }
public void SetAddDeck(int count, SkillBase skill) { }
public void SetBuffAdd(int addAttack, int addLife, bool isMinusZeroAttack, bool isMinusZeroLife, SkillBase skill, bool isDead, bool isMinus) { }
public void SetBuffAdd(int addAttack, int addLife, int gainAttack, int gainLife, SkillBase skill, bool isInHand) { }
public void SetBuffMultiply(int multiplyAttack, int multiplyLife, SkillBase skill) { }
public void SetBuffAddClass(SkillBase skill) { }
public void SetBuffSetLife(int setLife, bool isClass, SkillBase skill) { }
public void SetBuffAddMaxLife(int addMaxLife, SkillBase skill, bool isDead, bool isDebuffSkill) { }
public void SetBuffInHandAdd(int addAttack, int addLife, SkillBase skill = null, bool isTargetInOpponentHand = false) { }
public void SetBuffInDeckAdd(SkillBase skill, bool isPlayer, int addAttack, int addLife) { }
public void SetHeal(int healAmount) { }
public void SetHealSkill(SkillBase skill, int healAmount) { }
public void SetDamage(BattleCardBase damageAfter, SkillBase skill) { }
public void SetDestroy() { }
public void SetBanish() { }
public void SetMetamorphose(SkillBase skill = null) { }
public void SetUniteMaterial() { }
public void SetBerserkBySkill(SkillBase skill) { }
public void SetLose(SkillBase skill) { }
public void SetLoseCopiedSkill(SkillBase skill, bool isRemain) { }
public void SetChangeClan(CardBasePrm.ClanType newClan, SkillBase skill, bool isTargetInOpponentHand = false) { }
public void SetChangeTribe(List<CardBasePrm.TribeType> newTribe, SkillBase skill, bool isTargetInOpponentHand = false) { }
public void SetChangePlayCount(int num, SkillBase skill) { }
public void SetGain(SkillGainType type, BattleCardBase gainFrom, int val1 = 0, SkillBase skill = null) { }
public void SetAttachSkill(SkillBase attachedSkill, SkillBase skill, bool isTargetInOpponentHand = false) { }
public void SetShortageDeckWin(SkillBase skill) { }
public void SetTimingWhenPlay(LogType logType, SkillBase skill) { }
public void SetTimingWhenDestroy(SkillBase skill) { }
public void SetTimingWhenLeave(SkillBase skill) { }
public void SetTimingWhenAttackSelfAndOtherAfter(SkillBase skill) { }
public void SetTimingOther(SkillBase skill) { }
public void SetCostChangeCalculate(int num, SkillBase skill = null, bool isTargetInOpponentHand = false) { }
public void SetCostChange(SkillBase skill) { }
public void SetRandomArray(int[] randomArray) { }
public void SetCardTextureColorToGrey() { }
public void SetTokenDrawModifier() { }
public void SetUsePp(SkillBase skill, int usePp) { }
public void SetExclusionTargetList(SkillBase skill) { }
public void SetInnerInReplay(LogType type, string rightValueText, bool isNecromance, int mulliganCount) { }
public void SetInnerOnSkillTimingInReplay(LogType logType, bool isNecromance) { }
public void SetInnerOnDamageInReplay(LogType logType, BattleCardBase card, string rightValueText, bool isDead) { }
public void SetInnerOnHealInReplay(LogType logType, string rightValueText) { }
public void SetInnerOnSkillTargetInReplay(LogType type, bool isMinus, string logText, string rightValueText, bool isDead) { }
public void SetSummonCountInReplay(int summonCount) { }
public static bool IsSameSkillOwner(SkillBase skillA, SkillBase skillB) => default!;
public bool IsSameLog(BattleLogItem logItem) => default!;
public bool IsUseRightText() => default!;
public void SetActiveDammyFrame(bool active) { }
private void OnClickLog() { }
public void OnUnClickLog() { }
public void SetSelectSpriteActive(bool setActive) { }
}
}