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

@@ -81,8 +81,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
private int judgeResult_NotFinishNum;
private const int NOTFINISH_RETRYNUM = 5;
public NetworkBattleReceiver.RESULT_CODE JudgeResultReceiveCode;
protected ReceiveIntervalTrigger receiveIntervalTrigger;
@@ -169,11 +167,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
private List<int> LastCheckInplayWhiteRitualStackPair { get; set; } = new List<int> { 0, 0 };
public void SetIsSkillSelectTiming(bool val)
{
IsSkillSelectTiming = val;
}
public override void Update(float dt)
{
base.Update(dt);
@@ -225,7 +218,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
public override int GetMaxDeckCount(bool isSelf)
{
return GameMgr.GetIns().GetDataMgr().GetDeckMaxCount(isSelf);
return this.GameMgr.GetDataMgr().GetDeckMaxCount(isSelf);
}
public NetworkBattleManagerBase(IBattleMgrContentsCreator contentsCreator)
@@ -234,6 +227,13 @@ public class NetworkBattleManagerBase : BattleManagerBase
NetworkBattleManagerSetup();
}
// Phase-5 chunk 45: overload accepting a pre-seeded GameMgr.
public NetworkBattleManagerBase(IBattleMgrContentsCreator contentsCreator, GameMgr gameMgr)
: base(contentsCreator, gameMgr)
{
NetworkBattleManagerSetup();
}
protected override void FirstRecoverySetting()
{
}
@@ -250,15 +250,16 @@ public class NetworkBattleManagerBase : BattleManagerBase
TouchControl = new NetworkTouchControl(this, _battleCamera, _backGround);
networkTouchControl = TouchControl as NetworkTouchControl;
JudgeResultReceiveCode = NetworkBattleReceiver.RESULT_CODE.NotFinish;
if (base.IsRecovery || GameMgr.GetIns().IsReplayBattle)
// IsReplayBattle is const-false in headless (Phase-4 target): only IsRecovery can enter
// this branch, and its selfIdxSeed always uses the RecoveryManager path.
if (base.IsRecovery)
{
networkTouchControl.SetDisableTouch();
networkBattleData = new NetworkRecoveryBattleData(this);
networkReceiver = new NetworkReplayBattleReceiver(this);
OperateReceive = new RecoveryOperateReceive(this, RegisterActionManager, OperateMgr, networkBattleData);
int selfIdxSeed = (base.IsRecovery ? _contentsCreator.RecoveryManager.IdxChangeSeed : Data.ReplayBattleInfo.IdxChangeSeed);
int oppIdxSeed = (GameMgr.GetIns().IsReplayBattle ? Data.ReplayBattleInfo.OppoIdxChangeSeed : (-1));
CreateXorShift(selfIdxSeed, oppIdxSeed);
int selfIdxSeed = _contentsCreator.RecoveryManager.IdxChangeSeed;
CreateXorShift(selfIdxSeed, -1);
}
else
{
@@ -356,18 +357,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
};
}
public void SetPublishedActiveSkillCount(SkillCollectionBase skills)
{
for (int i = 0; i < skills.Count(); i++)
{
if (!skills.Get(i).SkillPrm.selfBattlePlayer.BattleMgr.IsVirtualBattle && !(skills.Get(i) is Skill_none))
{
skills.Get(i).SetPublishedActiveSkillCount(skills.Get(i).SkillPrm.selfBattlePlayer.BattleMgr.AllPublishedActiveSkillCount + base.TemporaryPublishedAddCount);
base.TemporaryPublishedAddCount++;
}
}
}
protected void SetupCreateBattleCardFunc(bool createCardWithoutGameObject)
{
if (createCardWithoutGameObject)
@@ -385,69 +374,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
}
public virtual void RecoveryEnd()
{
base.IsRecovery = false;
networkTouchControl.SetEnableTouch();
NetworkBattleData networkBattleData = this.networkBattleData;
this.networkBattleData = new NetworkBattleData(this);
this.networkBattleData.isPlayerMulliganEnd = networkBattleData.isPlayerMulliganEnd;
this.networkBattleData.isOppoMulliganEnd = networkBattleData.isOppoMulliganEnd;
this.networkBattleData.SetReceiveData(networkBattleData.GetReceiveData());
this.networkBattleData.isEnemyFirstTurn = networkBattleData.isEnemyFirstTurn;
_networkBattleSetupCardEventBase.OverwriteNetworkBattleData(this.networkBattleData);
SetupCreateBattleCardFunc(createCardWithoutGameObject: false);
OperateMgr operateMgr = OperateMgr;
OperateMgr = CreateOperateMgr();
OperateMgr.SetUpRecoveryEvent(operateMgr);
operateMgr = null;
OperateReceive = new OperateReceive(this, RegisterActionManager, OperateMgr, this.networkBattleData);
if (_phase is NetworkMulliganPhase)
{
(_phase as NetworkMulliganPhase).MulliganEventSetting();
}
operateReceiveChecker = new OperateReceiveChecker(this, this.networkBattleData);
networkReceiver = new NetworkBattleReceiver(this);
SetupNetworkEvent(isRecovery: true);
SetupReplayRecordingEvent();
if (_specialWinVfx == null)
{
ClearRegisterCardList();
}
}
private void SetupReplayRecordingEvent()
{
_contentsCreator.ReplayRecordManager.SetupOperateMgrEvents(this);
}
public virtual void RecoveryTimeOutSetting(float extendTime, bool isMulliganEnd, long startTime = -1L)
{
if (!isMulliganEnd)
{
if (MulliganMgr != null)
{
MulliganMgr.GetMulliganInfo().SetExtendTime(extendTime);
}
return;
}
if (!BattlePlayer.IsSelfTurn)
{
opponentNotTurnEndToWinChecker.StartChecker();
return;
}
if (turnEndTimeController == null)
{
TurnEndButtonUI component = SBattleLoad.m_TurnEndBtnUI.GetComponent<TurnEndButtonUI>();
turnEndTimeController = new TurnEndTimeController(this, BattlePlayer, component);
}
if (!turnEndTimeController.IsCountdownRunning())
{
turnEndTimeController.StartCountDown("SetTimeoutSetting");
}
turnEndTimeController.SetExtendTime(extendTime);
}
public void SetTimeDecrementFlag(bool isDecrement)
{
if (turnEndTimeController != null)
@@ -456,76 +382,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
}
public virtual void SetupFieldAndHandAfterRecovery(Action onEndRecoveryCallback, RecoveryOperationInfo aiBattleRecoveryData = null)
{
if (!Data.BattleRecoveryInfo.IsMulliganEnd)
{
SequentialVfxPlayer vfx = SequentialVfxPlayer.Create(MulliganMgr.RecoverMulligan(networkBattleData.isPlayerMulliganEnd, this), InstantVfx.Create(onEndRecoveryCallback));
base.VfxMgr.RegisterSequentialVfx(vfx);
return;
}
BattlePlayer.PlayerBattleView.ClearPlayQueue();
BattleEnemy.BattleEnemyView.ClearPlayQueue();
RecreateCardViews(BattlePlayer.InPlayCards);
RecreateCardViews(BattlePlayer.HandCardList);
RecreateCardViews(BattlePlayer.DeckCardList);
RecreateCardViews(BattlePlayer.ReservedCardList);
RecreateCardViews(BattleEnemy.InPlayCards);
RecreateCardViews(BattleEnemy.HandCardList);
RecreateCardViews(BattleEnemy.DeckCardList);
RecreateCardViews(BattleEnemy.ReservedCardList);
RefreshHealthVfx refreshHealthVfx = new RefreshHealthVfx(BattlePlayer);
RefreshHealthVfx refreshHealthVfx2 = new RefreshHealthVfx(BattleEnemy);
ParallelVfxPlayer parallelVfxPlayer = ParallelVfxPlayer.Create(BattlePlayer.BattleView.RecoveryInPlayCards(), BattlePlayer.BattleView.RecoveryInHandCards(), BattlePlayer.BattleView.RecoveryClassAndInPlayCardAttachSkillEffect(), BattleEnemy.BattleView.RecoveryInPlayCards(), BattleEnemy.BattleView.RecoveryInHandCards(), BattleEnemy.BattleView.RecoveryClassAndInPlayCardAttachSkillEffect(), refreshHealthVfx, refreshHealthVfx2);
ReinitializeTurnPanelControl();
VfxBase vfxBase = (BattlePlayer.IsSelfTurn ? BattlePlayer.BattleView.RecoveryTurnStart() : BattleEnemy.BattleEnemyView.RecoveryTurnStart());
ParallelVfxPlayer parallelVfxPlayer2 = ParallelVfxPlayer.Create(BattlePlayer.BattleView.RecoveryBattleUI(), BattleEnemy.BattleView.RecoveryBattleUI(), InstantVfx.Create(delegate
{
BattlePlayer.PlayerBattleView.ForceShowTurnEndButton();
}), vfxBase, RecoveryAfterMulliganPhase.RestoreUI(this));
VfxBase vfxBase2 = (BattleEnemy.IsSelfTurn ? BattleEnemy.CreateThinkingVfx(this) : NullVfx.GetInstance());
SequentialVfxPlayer vfx2 = SequentialVfxPlayer.Create(parallelVfxPlayer2, parallelVfxPlayer, HandViewBase.CreateHideCardMeshesVfx(BattleEnemy.HandCardList), vfxBase2, InstantVfx.Create(onEndRecoveryCallback), InstantVfx.Create(delegate
{
ResetLeaderAnimation(BattlePlayer, BattleEnemy);
}));
base.VfxMgr.RegisterSequentialVfx(vfx2);
}
protected void ResetLeaderAnimation(BattlePlayer battlePlayer, BattleEnemy battleEnemy)
{
PlayerClassBattleCardView playerClassBattleCardView = battlePlayer.Class.BattleCardView as PlayerClassBattleCardView;
playerClassBattleCardView.ClassCharacter.SetAnimationEnable(PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.SHOW_LEADER_ANIMATION));
if (battlePlayer.IsSkinEvolved)
{
playerClassBattleCardView.ClassCharacter.PlayMotion(ClassCharaPrm.MotionType.z_idle);
}
EnemyClassBattleCardView enemyClassBattleCardView = battleEnemy.Class.BattleCardView as EnemyClassBattleCardView;
enemyClassBattleCardView.ClassCharacter.SetAnimationEnable(PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.SHOW_LEADER_ANIMATION));
if (battleEnemy.IsSkinEvolved)
{
enemyClassBattleCardView.ClassCharacter.PlayMotion(ClassCharaPrm.MotionType.z_idle);
}
}
public void SendEchoRecovery(NetworkBattleReceiver.ReceiveData receiveData)
{
NetworkSender.SendEcho(-1, receiveData.actionType, sendKeyActionDataManager);
}
protected void RecreateCardViews(IEnumerable<BattleCardBase> cardList)
{
foreach (BattleCardBase card in cardList)
{
if (card.BattleCardView.IsNullView)
{
CardParameter cardParameterFromId = CardMaster.GetInstanceForBattle().GetCardParameterFromId(card.CardId);
GameObject cardGameObject = CreateBaseCardGameObject(cardParameterFromId, card.IsPlayer, card.Index);
SetupCardObjectMaterials(cardGameObject, card);
card.RecreateView(cardGameObject);
}
}
}
protected override int CreateBackgroundId()
{
if (PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.SIMPLE_STAGE))
@@ -537,7 +393,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
{
return backGroundId;
}
return GameMgr.GetIns().GetNetworkUserInfoData().GetFieldId();
return this.GameMgr.GetNetworkUserInfoData().GetFieldId();
}
protected override OperateMgr CreateOperateMgr()
@@ -558,10 +414,9 @@ public class NetworkBattleManagerBase : BattleManagerBase
{
base.StartOpening(FirstAttack);
TurnEndButtonUI component = SBattleLoad.m_TurnEndBtnUI.GetComponent<TurnEndButtonUI>();
if (!GameMgr.GetIns().IsAINetwork || turnEndTimeController == null)
{
turnEndTimeController = new TurnEndTimeController(this, BattlePlayer, component);
}
// IsAINetwork is const-false in headless — the guard `!false || X` is a tautology, so
// turnEndTimeController is always re-constructed on StartOpening.
turnEndTimeController = new TurnEndTimeController(this, BattlePlayer, component);
}
protected override void SetupEvent()
@@ -648,9 +503,9 @@ public class NetworkBattleManagerBase : BattleManagerBase
BattlePlayer.OnTurnEndStart += delegate
{
_isNoLimitJudgeResult = true;
if (ToolboxGame.RealTimeNetworkAgent != null)
if (this.InstanceNetworkAgent != null)
{
ToolboxGame.RealTimeNetworkAgent.ResetDisconnectLogNum();
this.InstanceNetworkAgent.ResetDisconnectLogNum();
}
};
BattleEnemy.OnTurnEndStart += delegate
@@ -861,12 +716,12 @@ public class NetworkBattleManagerBase : BattleManagerBase
protected virtual bool isNetworkOepn()
{
return ToolboxGame.RealTimeNetworkAgent.IsOpen();
return this.InstanceNetworkAgent.IsOpen();
}
private IEnumerator WaitNetworkBattleLoading()
{
while (ToolboxGame.RealTimeNetworkAgent == null)
while (this.InstanceNetworkAgent == null)
{
yield return null;
}
@@ -875,7 +730,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
yield return null;
}
FirstSettingRealTimeNetworkBattle();
int randomSeed = GameMgr.GetIns().GetNetworkUserInfoData().GetRandomSeed();
int randomSeed = this.GameMgr.GetNetworkUserInfoData().GetRandomSeed();
LocalLog.AccumulateLastTraceLog("657699SetSeed " + randomSeed);
_stableRandom = new System.Random(randomSeed);
_stableRandomOnlySelf = new System.Random(randomSeed);
@@ -883,16 +738,16 @@ public class NetworkBattleManagerBase : BattleManagerBase
protected void FirstSettingRealTimeNetworkBattle()
{
ToolboxGame.RealTimeNetworkAgent.SetNetworkBattleMgr(this);
this.InstanceNetworkAgent.SetNetworkBattleMgr(this);
}
public virtual void SettingOpponentAliveEvent()
{
NetworkStatus playerNetworkStatus = ToolboxGame.RealTimeNetworkAgent.PlayerNetworkStatus;
NetworkStatus playerNetworkStatus = this.InstanceNetworkAgent.PlayerNetworkStatus;
playerNetworkStatus.OnAlive = (Action)Delegate.Combine(playerNetworkStatus.OnAlive, new Action(OnPlayerAlive));
NetworkStatus opponentNetworkStatus = ToolboxGame.RealTimeNetworkAgent.OpponentNetworkStatus;
NetworkStatus opponentNetworkStatus = this.InstanceNetworkAgent.OpponentNetworkStatus;
opponentNetworkStatus.OnAlive = (Action)Delegate.Combine(opponentNetworkStatus.OnAlive, new Action(OpponentAliveCallback));
NetworkStatus opponentNetworkStatus2 = ToolboxGame.RealTimeNetworkAgent.OpponentNetworkStatus;
NetworkStatus opponentNetworkStatus2 = this.InstanceNetworkAgent.OpponentNetworkStatus;
opponentNetworkStatus2.OnDisconnect = (Action)Delegate.Combine(opponentNetworkStatus2.OnDisconnect, new Action(OpponentDisconnectCallback));
}
@@ -921,7 +776,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
};
operateMgr.OnSetCard += delegate(BattleCardBase card)
{
NetworkBattleSender.PlayActionLogMsg += "OnSetCard \n";
NowPlayCard = card;
};
if (base.IsRecovery)
@@ -930,57 +784,46 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
operateMgr.OnSetCardSuccess += delegate(BattleCardBase originalCard, BattleCardBase card, IEnumerable<BattleCardBase> selectedCard)
{
NetworkBattleSender.PlayActionLogMsg += "OnSetCardSuccess \n";
SettingPlaySelectCard(card.IsChoiceBraveSkillCard ? originalCard : card, selectedCard);
};
operateMgr.OnSetCardComplete += delegate
{
NetworkBattleSender.PlayActionLogMsg += "OnSetCardComplete \n";
if (_operatePlayCard != null && _operatePlayCard.IsPlayer)
{
SendPlayCard(_operatePlayCard, _operatePlaySelectCard, sendKeyActionDataManager);
initSelectData();
NetworkBattleSender.PlayActionLogMsg = "";
}
IsCardPlayToTurnEndTimeoutStop = false;
return NullVfx.GetInstance();
};
operateMgr.OnEvolveSuccess += delegate(BattleCardBase originalCard, BattleCardBase card, IEnumerable<BattleCardBase> selectedCard)
{
NetworkBattleSender.PlayActionLogMsg += "OnEvolveSuccess \n";
SettingPlaySelectCard(card, selectedCard);
};
operateMgr.OnEvoleComplete += delegate
{
NetworkBattleSender.PlayActionLogMsg += "OnEvoleComplete \n";
if (_operatePlayCard != null && _operatePlayCard.IsPlayer)
{
SendEvolveData(_operatePlayCard, _operatePlaySelectCard, sendKeyActionDataManager);
initSelectData();
NetworkBattleSender.PlayActionLogMsg = "";
}
return NullVfx.GetInstance();
};
operateMgr.OnPlayerAttack += delegate(BattleCardBase attackCard, BattleCardBase targetCard)
{
NetworkBattleSender.PlayActionLogMsg += "OnPlayerAttack \n";
SendAttackData(attackCard, targetCard);
NetworkBattleSender.PlayActionLogMsg = "";
return NullVfx.GetInstance();
};
operateMgr.OnBeforeFusion += delegate(BattleCardBase card, IEnumerable<BattleCardBase> selectedCard)
{
NetworkBattleSender.PlayActionLogMsg += "OnFusionSuccess \n";
SettingPlaySelectCard(card, selectedCard);
};
operateMgr.OnAfterFusion += delegate
{
NetworkBattleSender.PlayActionLogMsg += "OnFusionComplete \n";
if (_operatePlayCard != null && _operatePlayCard.IsPlayer)
{
SendFusionData(_operatePlayCard, _operatePlaySelectCard, sendKeyActionDataManager);
initSelectData();
NetworkBattleSender.PlayActionLogMsg = "";
}
return NullVfx.GetInstance();
};
@@ -1033,13 +876,13 @@ public class NetworkBattleManagerBase : BattleManagerBase
base.DisposeBattleGameObj();
BattleFinishToEffectClear();
BattleFinishToStopIntervalChecker();
ToolboxGame.DestroyNetworkAgent();
if (this.InstanceNetworkAgent is { } _agentToDestroy) { UnityEngine.Object.DestroyImmediate(_agentToDestroy.gameObject); this.InstanceNetworkAgent = null; }
StopJudgeResultCoroutine();
StopReconnectCorutine();
GameMgr.GetIns().IsNetworkBattle = false;
GameMgr.GetIns().IsWatchBattle = false;
GameMgr.GetIns().IsReplayBattle = false;
GameMgr.GetIns().IsNewReplayBattle = false;
// End-of-battle GameMgr flag resets dropped in Phase-3: three of the four flags are
// const-false in Phase-4 (IsWatchBattle / IsReplayBattle / IsNewReplayBattle) and can't
// be assigned; IsNetworkBattle stays true for the node's whole lifetime (the node IS a
// network battle) so resetting it here would be wrong for a subsequent battle anyway.
SettingNetworkBattleEnd();
}
@@ -1076,7 +919,8 @@ public class NetworkBattleManagerBase : BattleManagerBase
{
bool flag = false;
BattleCardBase battleCardBase = null;
if (!isPlayer && NetworkBattleGenericTool.GetCardPlaceState(BattleEnemy, index) == NetworkBattleDefine.NetworkCardPlaceState.Hand && !GameMgr.GetIns().IsAdmin)
// IsAdmin is const-false in headless — `!IsAdmin` is a tautology; dropped from the guard.
if (!isPlayer && NetworkBattleGenericTool.GetCardPlaceState(BattleEnemy, index) == NetworkBattleDefine.NetworkCardPlaceState.Hand)
{
flag = true;
battleCardBase = NetworkBattleGenericTool.GetIndexToCardBase(this, BattleEnemy, index);
@@ -1122,7 +966,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
{
RegisterActionManager.Add(new RegisterSpecialWin(winPlayer.IsPlayer));
BattleFinishToEffectClear();
base.VfxMgr.RegisterImmediateVfx(new CanNotTouchCardVfx());
base.VfxMgr.RegisterImmediateVfx(NullVfx.GetInstance());
_isSendSpecialWin = true;
bool playerDead = !winPlayer.IsPlayer;
_isSpecialWin = winPlayer.IsPlayer;
@@ -1134,7 +978,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
if (battlePlayer.IsShortageDeckWin)
{
BattleFinishToEffectClear();
base.VfxMgr.RegisterImmediateVfx(new CanNotTouchCardVfx());
base.VfxMgr.RegisterImmediateVfx(NullVfx.GetInstance());
_isSendSpecialWin = true;
_isSpecialWin = battlePlayer.IsPlayer;
}
@@ -1254,8 +1098,8 @@ public class NetworkBattleManagerBase : BattleManagerBase
base.VfxMgr.RegisterImmediateVfx(vfx2);
}
SelfDisconnectOffTouchRelease();
BattleManagerBase.GetIns().BattlePlayer.PlayerBattleView.OffNotHideAndNotCreate();
BattleManagerBase.GetIns().BattlePlayer.PlayerBattleView.HideAlertDialogue();
BattlePlayer.PlayerBattleView.OffNotHideAndNotCreate();
BattlePlayer.PlayerBattleView.HideAlertDialogue();
IsShowDisconnectPanel = false;
}
}
@@ -1264,78 +1108,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
}
public virtual void FinishBattleEffect(bool classDead)
{
BATTLE_RESULT_TYPE bATTLE_RESULT_TYPE = _finishEffectType;
if (_isNodeErrorToNocontest)
{
switch (BattleResultType)
{
case BATTLE_RESULT_TYPE.CONSISTENCY:
BattleResultControl.SetSpecialResultTypeText(Data.SystemText.Get("Battle_0481"));
break;
case BATTLE_RESULT_TYPE.WIN:
bATTLE_RESULT_TYPE = BATTLE_RESULT_TYPE.LOSE;
SettingResultUI_SpecialResultTypeText(bATTLE_RESULT_TYPE);
break;
case BATTLE_RESULT_TYPE.LOSE:
bATTLE_RESULT_TYPE = BATTLE_RESULT_TYPE.WIN;
SettingResultUI_SpecialResultTypeText(bATTLE_RESULT_TYPE);
break;
}
_isNodeErrorToNocontest = false;
}
bool isPlayer = false;
switch (bATTLE_RESULT_TYPE)
{
case BATTLE_RESULT_TYPE.WIN:
isPlayer = true;
break;
case BATTLE_RESULT_TYPE.LOSE:
isPlayer = false;
break;
case BATTLE_RESULT_TYPE.CONSISTENCY:
BattleResultControl.SetBattleFinishConsistency();
isPlayer = true;
classDead = false;
break;
}
if (classDead)
{
BattleCardBase battleCardBase = GetBattlePlayer(isPlayer).Class;
if (battleCardBase.Life >= 1 && !battleCardBase.IsDead)
{
battleCardBase.FlagCardAsDestroyedByKiller();
FINISH_TYPE finishTypeByStatus = GetFinishTypeByStatus();
base.VfxMgr.RegisterSequentialVfx(DeadClass(isPlayer, finishTypeByStatus));
}
}
base.VfxMgr.RegisterSequentialVfx(InstantVfx.Create(delegate
{
InitiateGameEndSequence(!isPlayer);
}));
}
public FINISH_TYPE GetFinishTypeByStatus()
{
FINISH_TYPE fINISH_TYPE = FINISH_TYPE.NORMAL;
switch (JudgeResultReceiveCode)
{
case NetworkBattleReceiver.RESULT_CODE.RetireWin:
case NetworkBattleReceiver.RESULT_CODE.RetireLose:
return FINISH_TYPE.RETIRE;
case NetworkBattleReceiver.RESULT_CODE.SpecialWin:
case NetworkBattleReceiver.RESULT_CODE.SpecialLose:
return FINISH_TYPE.SPECIAL_WIN;
default:
return FINISH_TYPE.NORMAL;
}
}
public void DebugFinishSend()
{
}
protected virtual void FinishBattleSend(NetworkBattleSender.JUDGE_RESULT_STATUS judgeResultStatus, bool isWin = false, bool isNotRetry = false)
{
LocalLog.AccumulateLastTraceLog("FinishSend " + judgeResultStatus);
@@ -1356,10 +1128,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
}
public void DebugJudgeResult()
{
}
private IEnumerator WaitToReconnectSocket()
{
WaitForSeconds wait = new WaitForSeconds(16f);
@@ -1395,7 +1163,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
public virtual void SendFinishBattleTask()
{
BattlePlayer.BattleView.HideTurnEndButton();
ToolboxGame.RealTimeNetworkAgent.FinishBattleTask();
this.InstanceNetworkAgent.FinishBattleTask();
}
private IEnumerator SendJudgeResultRetry()
@@ -1487,13 +1255,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
}
public void NodeErrorToNocontest()
{
_isNodeErrorToNocontest = true;
_finishEffectType = BATTLE_RESULT_TYPE.CONSISTENCY;
ToolboxGame.RealTimeNetworkAgent.FinishBattleTask();
}
private void StopJudgeResultCoroutine()
{
if (_checkJudgeResultToDisconnectCoroutine != null)
@@ -1515,7 +1276,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
UIManager instance = UIManager.GetInstance();
instance.dialogAllClear();
SettingNetworkBattleEnd();
ToolboxGame.DestroyNetworkAgent();
if (this.InstanceNetworkAgent is { } _agentToDestroy) { UnityEngine.Object.DestroyImmediate(_agentToDestroy.gameObject); this.InstanceNetworkAgent = null; }
DialogBase dialogBase = instance.CreateDialogClose(isSystem: true);
dialogBase.SetSize(DialogBase.Size.M);
if (isError)
@@ -1533,16 +1294,16 @@ public class NetworkBattleManagerBase : BattleManagerBase
dialogBase.SetFadeButtonEnabled(flag: false);
BattleFinishToStopIntervalChecker();
instance.closeInSceneCenterLoading();
BattleManagerBase.GetIns().BattlePlayer.PlayerBattleView.OffNotHideAndNotCreate();
BattleManagerBase.GetIns().BattlePlayer.PlayerBattleView.HideAlertDialogue();
BattlePlayer.PlayerBattleView.OffNotHideAndNotCreate();
BattlePlayer.PlayerBattleView.HideAlertDialogue();
}
}
protected void BeforeDisconnectLose()
{
if (ToolboxGame.RealTimeNetworkAgent != null)
if (this.InstanceNetworkAgent != null)
{
ToolboxGame.RealTimeNetworkAgent.ReconnectSocket();
this.InstanceNetworkAgent.ReconnectSocket();
}
}
@@ -1619,15 +1380,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
return NetworkBattleReceiver.RESULT_CODE.NotFinish;
}
private bool IsDisconnectLose()
{
if (disconnectToLoseChecker.IsSelfDisconnectLose())
{
return true;
}
return false;
}
private bool IsBackTitleOnDisconnect()
{
if (disconnectToLoseChecker.IsSelfDisConnectOnTimeout())
@@ -1647,7 +1399,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
if (JudgeCurrentFinishStatus() != NetworkBattleReceiver.RESULT_CODE.NotFinish)
{
RealTimeNetworkAgent realTimeNetworkAgent = ToolboxGame.RealTimeNetworkAgent;
RealTimeNetworkAgent realTimeNetworkAgent = this.InstanceNetworkAgent;
realTimeNetworkAgent.OnAck = (Action<Dictionary<string, object>>)Delegate.Combine(realTimeNetworkAgent.OnAck, new Action<Dictionary<string, object>>(AckEmitBattleFinish));
}
}
@@ -1665,7 +1417,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
protected virtual void AckEmitBattleFinish(Dictionary<string, object> objs)
{
RealTimeNetworkAgent realTimeNetworkAgent = ToolboxGame.RealTimeNetworkAgent;
RealTimeNetworkAgent realTimeNetworkAgent = this.InstanceNetworkAgent;
realTimeNetworkAgent.OnAck = (Action<Dictionary<string, object>>)Delegate.Remove(realTimeNetworkAgent.OnAck, new Action<Dictionary<string, object>>(AckEmitBattleFinish));
BattleFinishToTurnEndFinal(isSelfTurn: true);
}
@@ -1761,16 +1513,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
networkBattleData.AfterSettingReceiveData();
}
public void ConductReplayReceiveData(NetworkBattleReceiver.ReplayReceiveData receiveData)
{
networkBattleData.SetReceiveData(receiveData);
if (!_isJudgeResultReceive)
{
NewReplayOperationCollection networkOperationCollection = new NewReplayOperationCollection(this as NetworkReplayBattleMgr, receiveData, networkBattleData);
(OperateReceive as NewReplayOperateReceive).StartReplayOperate(networkOperationCollection, receiveData);
}
}
protected virtual NetworkOperationCollectionBase CreateNetworkOperationCollection(NetworkBattleReceiver.ReceiveData receivedData, bool isPlayer)
{
if (base.IsRecovery)
@@ -1919,10 +1661,8 @@ public class NetworkBattleManagerBase : BattleManagerBase
bool flag3 = skillConditionCheck.IsInvoked == skill.IsInvoked;
if (flag && skillConditionCheck.Index == index && flag2 && flag3)
{
if (GameMgr.GetIns().IsWatchBattle && skillConditionCheck.isOpponent == isPlayer)
{
return false;
}
// IsWatchBattle const-false in headless — the guarded `return false` was watch-mode
// dead code.
return skillConditionCheck.activate == 1;
}
}
@@ -1982,10 +1722,8 @@ public class NetworkBattleManagerBase : BattleManagerBase
networkTouchControl.notEvolCardFlag = true;
isStopOperateFlag = true;
BattlePlayer.PlayerBattleView.TurnEndButtonUI.HideBtn();
if (!GameMgr.GetIns().IsWatchBattle)
{
MenuButtonObject.SetActive(value: false);
}
// IsWatchBattle const-false — `!IsWatchBattle` is a tautology.
MenuButtonObject.SetActive(value: false);
BattlePlayer.PlayerBattleView.AllClear(popUpClose: true);
BattleCardBase hitCard = networkTouchControl._hitCard;
if (hitCard != null && hitCard.IsOnMove)
@@ -2033,11 +1771,6 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
}
public bool IsEchoWait()
{
return networkBattleData.isEchoWait;
}
private void OnPlayerAlive()
{
ConnectionReportTrigger.ConnectionReport(this);
@@ -2050,7 +1783,7 @@ public class NetworkBattleManagerBase : BattleManagerBase
public IEnumerable<BattleCardBase> RecoverySkillTarget(IEnumerable<BattleCardBase> skillTargets, int targetCount)
{
if (GameMgr.GetIns().IsNetworkBattle)
if (this.GameMgr.IsNetworkBattle)
{
return skillTargets;
}
@@ -2128,31 +1861,4 @@ public class NetworkBattleManagerBase : BattleManagerBase
}
return -1;
}
public void ReplaceDeckCardOnWatch(bool isPlayer, int idx, int id)
{
BattlePlayerBase battlePlayer = GetBattlePlayer(isPlayer);
BattleCardBase battleCardBase = battlePlayer.DeckCardList.FirstOrDefault((BattleCardBase c) => c.Index == idx);
if (CardMaster.GetInstanceForBattle().GetCardParameterFromId(id).CharType != CardBasePrm.CharaType.NORMAL)
{
int index = battlePlayer.DeckCardList.IndexOf(battleCardBase);
battleCardBase.GetBuildInfo.CardId = id;
battleCardBase = (battlePlayer.DeckCardList[index] = CardCreatorBase.CreateToken(battleCardBase.GetBuildInfo, createNullView: true));
}
battleCardBase.ReplaceParameterAndSkillOnDeck(id);
if (battleCardBase.HasDeckSelfSkill)
{
battlePlayer.AddDeckSkillCard(battleCardBase);
}
}
public void RecordSelectSkillInRecovery(NetworkBattleReceiver.ReceiveData receiveData)
{
OperateReceive.RecordSelectSkillInRecovery(receiveData);
}
public void CheckLatestReplayInfoInRecovery()
{
OperateReceive.CheckLatestReplayInfoInRecovery();
}
}