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:
@@ -36,40 +36,12 @@ public class TouchControl
|
||||
|
||||
private IBattlePlayerView _battleEnemyView;
|
||||
|
||||
public PlayerEmotion _playerEmotion;
|
||||
|
||||
private Vector3 _moveWorld;
|
||||
|
||||
private Vector3 _moveArrowWorld;
|
||||
|
||||
public BattleCardBase _hitCard;
|
||||
|
||||
private GameObject _arrowObject;
|
||||
|
||||
private DetailPanelTouchProcessor _detailPanelTouchProcessor;
|
||||
|
||||
private EvolutionTouchProcessor _evolutionTouchProcessor;
|
||||
|
||||
private const string TapEffectArea1Tag = "TapEffectArea1";
|
||||
|
||||
private const string TapEffectArea2Tag = "TapEffectArea2";
|
||||
|
||||
private const string EpPanelTag = "EpPanel";
|
||||
|
||||
private const string PlayerChoiceBraveButtonTag = "PlayerChoiceBraveButton";
|
||||
|
||||
private const string EnemyChoiceBraveButtonTag = "EnemyChoiceBraveButton";
|
||||
|
||||
public const string BattleUITag = "BattleUI";
|
||||
|
||||
private const string ClassButtonTag = "ClassBtn";
|
||||
|
||||
private const string FieldGimic1Tag = "FieldGimic1";
|
||||
|
||||
private const string FieldGimic2Tag = "FieldGimic2";
|
||||
|
||||
private const string FieldGimic3Tag = "FieldGimic3";
|
||||
|
||||
private BattleCardBase _detailCardDisplay;
|
||||
|
||||
private BattleCardBase _detailCardHover;
|
||||
@@ -92,10 +64,6 @@ public class TouchControl
|
||||
|
||||
public static BattleCardBase KeepAlertCard;
|
||||
|
||||
private const float HOVER_TIME = 0.2f;
|
||||
|
||||
private const float HOVER_HAND_ANGLE_MAX = 70f;
|
||||
|
||||
protected BattleCardBase _pressedCard;
|
||||
|
||||
public bool IsProcessorStart { get; private set; }
|
||||
@@ -141,7 +109,7 @@ public class TouchControl
|
||||
_predictionVfxMgr = new VfxMgr();
|
||||
_prediction = _battleMgr.Prediction;
|
||||
_classEffectVfxMgr = new VfxMgr();
|
||||
_inputMgr = GameMgr.GetIns().GetInputMgr();
|
||||
_inputMgr = _battleMgr.GameMgr.GetInputMgr();
|
||||
_battlePlayerView = battleMgr.BattlePlayer.PlayerBattleView;
|
||||
_battleEnemyView = battleMgr.BattleEnemy.BattleEnemyView;
|
||||
}
|
||||
@@ -178,7 +146,7 @@ public class TouchControl
|
||||
{
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
if (BattleManagerBase.GetIns().IsRecovery)
|
||||
if (_battleMgr.IsRecovery)
|
||||
{
|
||||
return NullVfx.GetInstance();
|
||||
}
|
||||
@@ -320,7 +288,7 @@ public class TouchControl
|
||||
flag = TryZoomHand(hits, array);
|
||||
}
|
||||
}
|
||||
else if (GameMgr.GetIns().IsAdmin && _inputMgr.IsDown())
|
||||
else if (_battleMgr.GameMgr.IsAdmin && _inputMgr.IsDown())
|
||||
{
|
||||
if (_battlePlayerView.IsDetailOn() && array == null)
|
||||
{
|
||||
@@ -460,7 +428,7 @@ public class TouchControl
|
||||
if (BattleManagerBase.UseCustomMouse && !array.Any((RaycastHit entry) => entry.collider.CompareTag("BattleUI")))
|
||||
{
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(_battlePlayerView.HandUnfocus());
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_HAND_MOVE_RIGHT);
|
||||
|
||||
}
|
||||
return parallelVfxPlayer;
|
||||
}
|
||||
@@ -471,7 +439,7 @@ public class TouchControl
|
||||
{
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(_battlePlayerView.HandUnfocus());
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(_battleEnemyView.HandUnfocus());
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_HAND_MOVE_RIGHT);
|
||||
|
||||
}
|
||||
if (flag2)
|
||||
{
|
||||
@@ -486,11 +454,11 @@ public class TouchControl
|
||||
{
|
||||
if (CheckChoiceBraveButton(hits, "PlayerChoiceBraveButton"))
|
||||
{
|
||||
BattleCardBase battleCardBase2 = BattleManagerBase.GetIns().BattlePlayer.Class;
|
||||
if (!GameMgr.GetIns().IsWatchBattle && BattlePlayer.CanChoiceBrave)
|
||||
BattleCardBase battleCardBase2 = _battleMgr.BattlePlayer.Class;
|
||||
if (!_battleMgr.GameMgr.IsWatchBattle && BattlePlayer.CanChoiceBrave)
|
||||
{
|
||||
ResetDetail();
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_HBP_BUTTON);
|
||||
|
||||
_battlePlayerView.UpdateChoiceBraveActivatingEffect(isActivating: true);
|
||||
List<SkillBase> choiceSkills = battleCardBase2.Skills.Where((SkillBase s) => s is Skill_choice && s.OnWhenChoiceBrave != 0).ToList();
|
||||
parallelVfxPlayer.Register(RegisterTouchProcessor(new ChoiceBraveTouchProcessor(_battleMgr, battleCardBase2, choiceSkills)));
|
||||
@@ -503,7 +471,7 @@ public class TouchControl
|
||||
}
|
||||
if (CheckChoiceBraveButton(hits, "EnemyChoiceBraveButton") && flag2)
|
||||
{
|
||||
BattleCardBase card = BattleManagerBase.GetIns().BattleEnemy.Class;
|
||||
BattleCardBase card = _battleMgr.BattleEnemy.Class;
|
||||
StartOpenHandDetail(card, right: false, isChoiceBraveButton: true);
|
||||
}
|
||||
}
|
||||
@@ -529,7 +497,7 @@ public class TouchControl
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((_hitCard.IsPlayer || GameMgr.GetIns().IsWatchBattle) && _hitCard.IsInHand && (GameMgr.GetIns().IsAdmin || _hitCard.IsPlayer))
|
||||
else if ((_hitCard.IsPlayer || _battleMgr.GameMgr.IsWatchBattle) && _hitCard.IsInHand && (_battleMgr.GameMgr.IsAdmin || _hitCard.IsPlayer))
|
||||
{
|
||||
SelectCardProcessor touchProcessor4 = new SelectCardProcessor(_battleMgr, _hitCard, _inputMgr, _pressedCard != null);
|
||||
parallelVfxPlayer.Register(RegisterTouchProcessor(touchProcessor4));
|
||||
@@ -608,7 +576,7 @@ public class TouchControl
|
||||
hits = Physics.RaycastAll(ray.origin, ray.direction, float.PositiveInfinity);
|
||||
}
|
||||
bool flag5 = true;
|
||||
if (BattleManagerBase.GetIns().IsPuzzleMgr)
|
||||
if (_battleMgr.IsPuzzleMgr)
|
||||
{
|
||||
_ = new RaycastHit[0];
|
||||
Ray ray3 = UIManager.GetInstance().getCamera().ScreenPointToRay(mousePosition);
|
||||
@@ -646,15 +614,15 @@ public class TouchControl
|
||||
{
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(_battlePlayerView.HandFocus());
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(_battleEnemyView.HandUnfocus());
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_HAND_MOVE_CENTER);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (GameMgr.GetIns().IsAdminWatch && !battleCardBase.IsPlayer && BattleEnemy.HandCardList.Count > 0)
|
||||
else if (_battleMgr.GameMgr.IsAdminWatch && !battleCardBase.IsPlayer && BattleEnemy.HandCardList.Count > 0)
|
||||
{
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(_battlePlayerView.HandUnfocus());
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(_battleEnemyView.HandFocus());
|
||||
GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_HAND_MOVE_CENTER);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -721,7 +689,7 @@ public class TouchControl
|
||||
public BattleCardBase TouchCard(RaycastHit[] hits)
|
||||
{
|
||||
BattleCardBase result = null;
|
||||
if (!GameMgr.GetIns().IsWatchBattle && (!_battlePlayerView.IsTouchable() || _battlePlayerView.IsSelecting))
|
||||
if (!_battleMgr.GameMgr.IsWatchBattle && (!_battlePlayerView.IsTouchable() || _battlePlayerView.IsSelecting))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
@@ -837,7 +805,6 @@ public class TouchControl
|
||||
{
|
||||
_pressedCard = null;
|
||||
_battlePlayerView.CancelCardDrag(card);
|
||||
ImmediateVfxMgr.GetInstance().Register(card.BattleCardView.ShowHandCardInfo(isRecovery: false, modifyParameterLabel: false));
|
||||
_prediction.Clear();
|
||||
}
|
||||
|
||||
@@ -907,7 +874,7 @@ public class TouchControl
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(ParallelVfxPlayer.Create(InstantVfx.Create(delegate
|
||||
{
|
||||
_battlePlayerView.ShowDetailPanel(_battleMgr, _battleMgr.OperateMgr, targetCard, DetailPanelControl.ShowRequest.EVOLUTION_SELECT);
|
||||
}), new StartEvolutionTargetFocusVfx(targetCard.BattleCardView.GameObject), new EvolutionHideMessageVfx(_battleMgr, _battleMgr.BattleResourceMgr)));
|
||||
}), NullVfx.GetInstance(), NullVfx.GetInstance()));
|
||||
EmitHandUtility.SendSlideObject(_battleMgr, NetworkBattleSender.SLIDE_OBJECT_TYPE.Evolve, targetCard);
|
||||
}
|
||||
return NullVfx.GetInstance();
|
||||
@@ -918,7 +885,7 @@ public class TouchControl
|
||||
if (targetCard != null)
|
||||
{
|
||||
this.OnEvolveUnfocus.Call();
|
||||
parallelVfxPlayer.Register(new StopEvolutionTargetFocasVfx(targetCard.BattleCardView.GameObject));
|
||||
parallelVfxPlayer.Register(NullVfx.GetInstance());
|
||||
parallelVfxPlayer.Register(InstantVfx.Create(delegate
|
||||
{
|
||||
HideDetailPanel();
|
||||
@@ -939,7 +906,7 @@ public class TouchControl
|
||||
_backGround.SetShaderGlobalColorBG.ChangeGlobalShaderColorFadeIn();
|
||||
}
|
||||
}
|
||||
}), new StopEvolutionChoiceEffectVfx(_battlePlayerView.EpIcon), PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.CONFIRM_EVOLVE) ? _battleMgr.DetailMgr.DetailPanelControl.ShowEvolutionButton(targetCard) : NullVfx.GetInstance()));
|
||||
}), NullVfx.GetInstance(), PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.CONFIRM_EVOLVE) ? _battleMgr.DetailMgr.DetailPanelControl.ShowEvolutionButton(targetCard) : NullVfx.GetInstance()));
|
||||
return NullVfx.GetInstance();
|
||||
};
|
||||
EvolutionTouchProcessor evolutionTouchProcessor = _evolutionTouchProcessor;
|
||||
@@ -947,7 +914,7 @@ public class TouchControl
|
||||
_evolutionTouchProcessor.OnNotSelectTarget += delegate
|
||||
{
|
||||
_battlePlayerView.DragArrowStop(_battleMgr);
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(new StopEvolutionChoiceEffectVfx(_battlePlayerView.EpIcon));
|
||||
_battleMgr.VfxMgr.RegisterImmediateVfx(NullVfx.GetInstance());
|
||||
EmitHandUtility.SendSlideObject(_battleMgr, NetworkBattleSender.SLIDE_OBJECT_TYPE.Cancel);
|
||||
};
|
||||
Exit();
|
||||
@@ -1102,27 +1069,6 @@ public class TouchControl
|
||||
return new ClassBuffTouchProcessor(battleMgr, touchClass, inputMgr);
|
||||
}
|
||||
|
||||
public static GameObject FindTouchPositionObject(IEnumerable<GameObject> gameObjects, Camera camera)
|
||||
{
|
||||
if (gameObjects == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Ray ray = camera.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit[] array = Physics.RaycastAll(ray.origin, ray.direction, float.PositiveInfinity);
|
||||
foreach (GameObject gameObject in gameObjects)
|
||||
{
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
if (array[i].collider.gameObject == gameObject)
|
||||
{
|
||||
return gameObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static bool CanInPlayCardBeDragged(BattleCardBase attackCard, BattlePlayerBase battlePlayer)
|
||||
{
|
||||
if (battlePlayer.IsSelfTurn && attackCard.IsPlayer && attackCard.IsUnit && attackCard.Attackable)
|
||||
@@ -1163,10 +1109,7 @@ public class TouchControl
|
||||
|
||||
private void checkHoverCard(RaycastHit[] hits, bool isZoomHand)
|
||||
{
|
||||
if (OptionSettingWindow.ShortcutDetailPanel != OptionSettingWindow.ShortcutDetail.Auto)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// OptionSettingWindow removed (DEAD-COLD engine cleanup Task 13) — Auto is the headless default; guard removed
|
||||
BattleCardBase battleCardBase = TouchCard(hits);
|
||||
BattleCardBase battleCardBase2 = null;
|
||||
if (KeepAlertCard != null && KeepAlertCard == battleCardBase && IsShowingAlert())
|
||||
@@ -1182,15 +1125,15 @@ public class TouchControl
|
||||
flag = battleCardBase.IsClass;
|
||||
flag3 = battleCardBase.IsHoverActionCard();
|
||||
}
|
||||
else if (CheckChoiceBraveButton(hits, "PlayerChoiceBraveButton") && (GameMgr.GetIns().IsWatchBattle || !BattlePlayer.CanChoiceBrave))
|
||||
else if (CheckChoiceBraveButton(hits, "PlayerChoiceBraveButton") && (_battleMgr.GameMgr.IsWatchBattle || !BattlePlayer.CanChoiceBrave))
|
||||
{
|
||||
flag2 = true;
|
||||
battleCardBase = BattleManagerBase.GetIns().BattlePlayer.Class;
|
||||
battleCardBase = _battleMgr.BattlePlayer.Class;
|
||||
}
|
||||
else if (CheckChoiceBraveButton(hits, "EnemyChoiceBraveButton"))
|
||||
{
|
||||
flag2 = true;
|
||||
battleCardBase = BattleManagerBase.GetIns().BattleEnemy.Class;
|
||||
battleCardBase = _battleMgr.BattleEnemy.Class;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1274,49 +1217,18 @@ public class TouchControl
|
||||
}
|
||||
}
|
||||
|
||||
private bool UsePlayShortcut()
|
||||
{
|
||||
return OptionSettingWindow.ShortcutPlay switch
|
||||
{
|
||||
OptionSettingWindow.Shortcut.RightClick => Input.GetMouseButtonDown(1),
|
||||
OptionSettingWindow.Shortcut.MiddleClick => Input.GetMouseButtonDown(2),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
// OptionSettingWindow removed (DEAD-COLD engine cleanup Task 13) — shortcut methods return false (headless default)
|
||||
private bool UsePlayShortcut() => false;
|
||||
|
||||
private bool UseEvolutionShortcut()
|
||||
{
|
||||
return OptionSettingWindow.ShortcutEvolution switch
|
||||
{
|
||||
OptionSettingWindow.Shortcut.RightClick => Input.GetMouseButtonDown(1),
|
||||
OptionSettingWindow.Shortcut.MiddleClick => Input.GetMouseButtonDown(2),
|
||||
OptionSettingWindow.Shortcut.DoubleClick => _inputMgr.IsDoubleClick(),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
private bool UseEvolutionShortcut() => false;
|
||||
|
||||
private bool UseDetailShortcut()
|
||||
{
|
||||
return OptionSettingWindow.ShortcutDetailPanel switch
|
||||
{
|
||||
OptionSettingWindow.ShortcutDetail.RightClick => Input.GetMouseButtonDown(1),
|
||||
OptionSettingWindow.ShortcutDetail.MiddleClick => Input.GetMouseButtonDown(2),
|
||||
OptionSettingWindow.ShortcutDetail.DoubleClick => _inputMgr.IsDoubleClick(),
|
||||
OptionSettingWindow.ShortcutDetail.LongPress => _inputMgr.IsLongPress(),
|
||||
_ => false,
|
||||
};
|
||||
}
|
||||
private bool UseDetailShortcut() => false;
|
||||
|
||||
public Prediction GetPrediction()
|
||||
{
|
||||
return _prediction;
|
||||
}
|
||||
|
||||
public void SelectCancelActCard()
|
||||
{
|
||||
_battleMgr.OperateMgr.SelectCancel(_hitCard);
|
||||
}
|
||||
|
||||
protected virtual void StopDraggingArrow()
|
||||
{
|
||||
_battlePlayerView.DragArrowStop(_battleMgr);
|
||||
|
||||
Reference in New Issue
Block a user