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

@@ -58,8 +58,6 @@ public class OperateMgr
public event Action<BattleCardBase, BattleCardBase> OnAttackStart;
public event Action<BattleCardBase> OnBeforeEvolve;
public event Action<BattleCardBase, BattleCardBase, IEnumerable<BattleCardBase>> OnEvolveSuccess;
public event Action<BattleCardBase> OnJustBeforeEvolve;
@@ -116,22 +114,10 @@ public class OperateMgr
public event Action<bool> OnClearSideLog;
public event Action<NetworkBattleReplayOperationRecorder.RecordBattleLogParameter> OnCreateBattleLog;
public event Action<BattleCardBase, bool, LogType, string, bool, bool> OnUpdateBattleLog;
public event Action<BattleCardBase, bool, LogType, LogType> OnUpdateBattleLogType;
public event Action<BattleCardBase, bool, LogType, bool> OnUpdateBattleLogIsNecromance;
public event Action OnRemoveLatestBattleLog;
public event Action<SkillCreator.SkillBuildInfo, List<BattleCardBase>, BattleCardBase> OnAttachSkill;
public event Action<SkillCreator.SkillBuildInfo, bool, bool, bool, bool> OnCreateEffect;
public event Action<string, EffectMgr.EngineType, EffectMgr.MoveType, EffectMgr.TargetType, float> OnCreateEffectWithoutBuildInfo;
public event Action<BattleCardBase, List<BattleCardBase>> OnShowSkillEffect;
public event Action<SkillBase, bool> OnSkillInductionEffect;
@@ -160,16 +146,8 @@ public class OperateMgr
public event Action<BattleCardBase> OnSpecialLose;
public event Action<BattlePlayerBase, BattlePlayerBase, bool, bool, bool> OnEnterForceBerserk;
public event Action<bool, bool> OnTurnEndFinish;
public void SetUpRecoveryEvent(OperateMgr recoveryOperateMgr)
{
this.OnBeforeAttack = recoveryOperateMgr.OnBeforeAttack;
this.OnTurnEnd_ButtonPush = recoveryOperateMgr.OnTurnEnd_ButtonPush;
}
public OperateMgr(BattleManagerBase battleMgr, TouchControl touchControl)
{
_battleMgr = battleMgr;
@@ -195,8 +173,8 @@ public class OperateMgr
{
this.OnBeforeSetCard.Call(card);
SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
bool isSelectTarget = GameMgr.GetIns().IsAdminWatch && (isAccelerateSelect || card.Skills.CheckWhenPlaySelectTargetSkillCondition);
if (isPlayer || GameMgr.GetIns().IsAdminWatch)
bool isSelectTarget = _battleMgr.GameMgr.IsAdminWatch && (isAccelerateSelect || card.Skills.CheckWhenPlaySelectTargetSkillCondition);
if (isPlayer || _battleMgr.GameMgr.IsAdminWatch)
{
PlayQueueViewBase playQueueView = _battleMgr.GetBattlePlayer(isPlayer).BattleView.PlayQueueView;
_battleMgr.VfxMgr.RegisterImmediateVfx(card.StopSpellCharge());
@@ -204,7 +182,7 @@ public class OperateMgr
if (registerDirectlyToVfxManager)
{
_battleMgr.VfxMgr.RegisterImmediateVfx(vfx);
if (!isPlayer && GameMgr.GetIns().IsAdminWatch && !isSelect && !isAccelerateSelect && !isFusionWait)
if (!isPlayer && _battleMgr.GameMgr.IsAdminWatch && !isSelect && !isAccelerateSelect && !isFusionWait)
{
sequentialVfxPlayer.Register(WaitVfx.Create(0.5f));
}
@@ -325,11 +303,6 @@ public class OperateMgr
return actionProcessor;
}
public void BeforeEvolutionCard(BattleCardBase card)
{
this.OnBeforeEvolve.Call(card);
}
public virtual VfxBase EvolutionCard(BattleCardBase card, bool isPlayer, List<BattleCardBase> selectCards, List<int> selectChoiceId = null)
{
if (selectCards != null)
@@ -405,7 +378,7 @@ public class OperateMgr
{
_PlayerBattleView.UpdateTurnEndPulseEffect();
}
if (GameMgr.GetIns().IsWatchBattle)
if (_battleMgr.GameMgr.IsWatchBattle)
{
_battleMgr.GetBattlePlayer(isPlayer).BattleView.ClearSelectCardList();
}
@@ -436,7 +409,7 @@ public class OperateMgr
public virtual VfxBase BattleCardSelect(BattleCardBase actCard, List<BattleCardBase> targets, bool isPlayer, bool registerEffectsDirectlyToVfxMgr = true, bool isTransformskill = false, bool isBurialRiteSkill = false, bool isComplete = true)
{
SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
if (isPlayer || GameMgr.GetIns().IsAdminWatch || GameMgr.GetIns().IsReplayBattle)
if (isPlayer || _battleMgr.GameMgr.IsAdminWatch || _battleMgr.GameMgr.IsReplayBattle)
{
foreach (BattleCardBase target in targets)
{
@@ -469,8 +442,8 @@ public class OperateMgr
{
return InstantVfx.Create(delegate
{
GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_CARD_SELECT_3, targetCard.BattleCardView.GameObject.transform.position);
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_CMN_CARD_SELECT_3);
_battleMgr.GameMgr.GetEffectMgr().Start(EffectMgr.EffectType.CMN_CARD_SELECT_3, targetCard.BattleCardView.GameObject.transform.position);
});
}
@@ -478,7 +451,7 @@ public class OperateMgr
{
SequentialVfxPlayer sequentialVfxPlayer = SequentialVfxPlayer.Create();
targetCard.IsSelectedDuringSelectingBurialRiteTarget = isBurialRiteSkill;
if (isPlayer || GameMgr.GetIns().IsAdminWatch || GameMgr.GetIns().IsReplayBattle)
if (isPlayer || _battleMgr.GameMgr.IsAdminWatch || _battleMgr.GameMgr.IsReplayBattle)
{
if (registerSelectStopVfxDirectlyToVfxMgr)
{
@@ -531,33 +504,17 @@ public class OperateMgr
battlePlayer.HandControl.RearrangeHand(0.3f, battlePlayer.HandCardList.ConvertToViewList());
}));
}
if (GameMgr.GetIns().IsWatchBattle)
if (_battleMgr.GameMgr.IsWatchBattle)
{
_battleMgr.VfxMgr.RegisterImmediateVfx(InstantVfx.Create(delegate
{
BattleManagerBase.GetIns().GetBattlePlayer(isPlayer).ClassInformationUIController.SetIsSelect(isSelect: false);
_battleMgr.GetBattlePlayer(isPlayer).ClassInformationUIController.SetIsSelect(isSelect: false);
}));
battlePlayer.BattleView.ClearSelectCardList();
}
this.OnSkillCardSelectSuccess = null;
}
public void ChoiceCancel(BattleCardBase actCard)
{
_battleMgr.BattlePlayer.PlayerBattleView.RearrangeHand();
if (_battleMgr.BattlePlayer.HandCardList.Contains(actCard))
{
_battleMgr.BattlePlayer.HandControl.AttachCardView(actCard.BattleCardView);
actCard.BattleCardView.GameObject.SetActive(value: true);
}
_TouchControl._hitCard = null;
_PlayerBattleView.DisableSettingFlag();
_PlayerBattleView.AllClear();
_PlayerBattleView.StopShowSelect(actCard, isAct: false);
_battleMgr.VfxMgr.RegisterImmediateVfx(ParallelVfxPlayer.Create(actCard.StartHandEffect(), actCard.IsInHand ? actCard.BattleCardView.ShowHandCardInfo() : NullVfx.GetInstance()));
this.OnSkillCardSelectSuccess = null;
}
public void StartSelectCard(BattleCardBase card, bool isEvolve, List<BattleCardBase> selectableCards, bool isChoiceBrave)
{
this.OnStartSelect.Call(card, isEvolve, selectableCards, isChoiceBrave);
@@ -649,31 +606,6 @@ public class OperateMgr
this.OnClearSideLog.Call(isSelf);
}
public void CallOnCreateBattleLog(NetworkBattleReplayOperationRecorder.RecordBattleLogParameter recordParameter)
{
this.OnCreateBattleLog.Call(recordParameter);
}
public void CallOnUpdateBattleLog(BattleCardBase card, bool isSelf, LogType type, string valueText, bool isSummon, bool isDead)
{
this.OnUpdateBattleLog.Call(card, isSelf, type, valueText, isSummon, isDead);
}
public void CallOnUpdateBattleLogType(BattleCardBase card, bool isSelf, LogType oldType, LogType newType)
{
this.OnUpdateBattleLogType.Call(card, isSelf, oldType, newType);
}
public void CallOnUpdateBattleLogIsNecromance(BattleCardBase card, bool isSelf, LogType type, bool isNecromance)
{
this.OnUpdateBattleLogIsNecromance.Call(card, isSelf, type, isNecromance);
}
public void CallOnRemoveLatestBattleLog()
{
this.OnRemoveLatestBattleLog.Call();
}
public void CallOnAttachSkill(SkillCreator.SkillBuildInfo buildInfo, List<BattleCardBase> targetCards, BattleCardBase ownerCard)
{
this.OnAttachSkill.Call(buildInfo, targetCards, ownerCard);
@@ -684,11 +616,6 @@ public class OperateMgr
this.OnCreateEffect.Call(buildInfo, isFollowInHand, isTargetPosition, addToLastOperation, isWhenFusioned);
}
public void CallOnEffect(string effectPath, EffectMgr.EngineType engineType, EffectMgr.MoveType effectMoveType, EffectMgr.TargetType effectTargetType, float effectTime)
{
this.OnCreateEffectWithoutBuildInfo.Call(effectPath, engineType, effectMoveType, effectTargetType, effectTime);
}
public void CallOnShowSkillEffect(BattleCardBase card, List<BattleCardBase> targetCards)
{
this.OnShowSkillEffect.Call(card, targetCards);
@@ -759,11 +686,6 @@ public class OperateMgr
this.OnSpecialLose.Call(card);
}
public void CallOnEnterForceBerserk(BattlePlayerBase player, BattlePlayerBase enemys, bool isPlayer)
{
this.OnEnterForceBerserk.Call(player, enemys, arg3: false, isPlayer, !isPlayer);
}
public void CallOnTurnEndFinish()
{
this.OnTurnEndFinish.Call(arg1: true, arg2: true);
@@ -806,7 +728,7 @@ public class OperateMgr
if (isPlayer)
{
this.OnBeforePlayerTurnEnd.Call();
if (GameMgr.GetIns().IsWatchBattle)
if (_battleMgr.GameMgr.IsWatchBattle)
{
_battleMgr.BattlePlayer.IsChoiceBraveEffectTiming = false;
_battleMgr.BattlePlayer.BattleView.UpdateChoiceBraveButtonPulsateEffectAndSprite();
@@ -820,7 +742,7 @@ public class OperateMgr
{
((NetworkBattleManagerBase)_battleMgr).SetTimeDecrementFlag(isDecrement: true);
}
if (GameMgr.GetIns().IsAdminWatch)
if (_battleMgr.GameMgr.IsAdminWatch)
{
_battleMgr.BattleEnemy.UpdateHandCardsPlayability(areArrowsForcedOff: true);
}