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:
@@ -7,422 +7,7 @@ using Wizard;
|
||||
|
||||
public class LoadingInScene : MonoBehaviour
|
||||
{
|
||||
private const string LOAD_TITLE = "Load_Title";
|
||||
|
||||
private const string LOAD_DESC = "Load_Desc";
|
||||
|
||||
private const string CARD_MASK_PATH = "loading_battle_mask";
|
||||
|
||||
public const int LOADING_TIPS_INDEX_MIN = 1;
|
||||
|
||||
private static int loadingTipsIndexMax;
|
||||
|
||||
[SerializeField]
|
||||
private UILabel LoadingLabel;
|
||||
|
||||
[SerializeField]
|
||||
private UIAnchor Anchor;
|
||||
|
||||
[SerializeField]
|
||||
private LoadingBase Progress;
|
||||
|
||||
[SerializeField]
|
||||
private bool Matching;
|
||||
|
||||
[SerializeField]
|
||||
private bool Battle;
|
||||
|
||||
[SerializeField]
|
||||
private bool ShowProgress;
|
||||
|
||||
[SerializeField]
|
||||
private NguiObjs LoadingTextObj;
|
||||
|
||||
[SerializeField]
|
||||
private UILabel LoadingCountLabel;
|
||||
|
||||
[SerializeField]
|
||||
private bool notText;
|
||||
|
||||
[SerializeField]
|
||||
private UITexture BGTexture;
|
||||
|
||||
[SerializeField]
|
||||
private UIPanel _fadeBlackPanel;
|
||||
|
||||
private int DotCnt;
|
||||
|
||||
private Coroutine _coroutineTextAnimation;
|
||||
|
||||
private Texture2D cardMask;
|
||||
|
||||
private List<string> resourcePathList;
|
||||
|
||||
public static int LoadingTipsIndexMax
|
||||
{
|
||||
get
|
||||
{
|
||||
if (loadingTipsIndexMax == 0)
|
||||
{
|
||||
loadingTipsIndexMax = Data.SystemText.Count("Load_Title");
|
||||
}
|
||||
return loadingTipsIndexMax;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsFadeout { get; set; }
|
||||
|
||||
public LoadingBase ProgressObj => Progress;
|
||||
|
||||
public void SetShowProgress(bool enable, bool immediate = false)
|
||||
{
|
||||
ShowProgress = enable;
|
||||
float num = (enable ? 1f : 0f);
|
||||
if (immediate)
|
||||
{
|
||||
if ((bool)Anchor)
|
||||
{
|
||||
UISprite component = Anchor.GetComponent<UISprite>();
|
||||
if ((bool)component)
|
||||
{
|
||||
component.alpha = 1f - num;
|
||||
}
|
||||
}
|
||||
if ((bool)Progress)
|
||||
{
|
||||
UISprite component2 = Progress.GetComponent<UISprite>();
|
||||
if ((bool)component2)
|
||||
{
|
||||
component2.alpha = num;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((bool)Anchor)
|
||||
{
|
||||
TweenAlpha.Begin(Anchor.gameObject, 0.5f, 1f - num);
|
||||
}
|
||||
if ((bool)Progress)
|
||||
{
|
||||
TweenAlpha.Begin(Progress.gameObject, 0.5f, num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
IsFadeout = false;
|
||||
DotCnt = 0;
|
||||
float num = (ShowProgress ? 1f : 0f);
|
||||
if ((bool)Anchor)
|
||||
{
|
||||
TweenAlpha.Begin(Anchor.gameObject, 0f, 1f - num);
|
||||
}
|
||||
if ((bool)Progress)
|
||||
{
|
||||
TweenAlpha.Begin(Progress.gameObject, 0f, num);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator SetLoadingText()
|
||||
{
|
||||
if (Battle)
|
||||
{
|
||||
List<int> allCardIds = CardMaster.GetInstanceForBattle().GetAllCardIds();
|
||||
int count = allCardIds.Count;
|
||||
CardParameter cardParameterFromId;
|
||||
int cardID;
|
||||
ResourcesManager.AssetLoadPathType pathType;
|
||||
while (true)
|
||||
{
|
||||
cardID = ((Data.Load.data._userTutorial.tutorial_step == 100) ? allCardIds[UnityEngine.Random.Range(0, count)] : (UnityEngine.Random.Range(0, 10) switch
|
||||
{
|
||||
1 => 101111070,
|
||||
2 => 101011010,
|
||||
3 => 100011030,
|
||||
4 => 101121020,
|
||||
5 => 101111020,
|
||||
6 => 101121040,
|
||||
7 => 101021020,
|
||||
8 => 101014010,
|
||||
9 => 101014030,
|
||||
_ => 101114040,
|
||||
}));
|
||||
cardParameterFromId = CardMaster.GetInstanceForBattle().GetCardParameterFromId(cardID);
|
||||
cardParameterFromId = CardMaster.GetInstanceForBattle().GetCardParameterFromId(cardParameterFromId.BaseCardId);
|
||||
cardID = cardParameterFromId.BaseCardId;
|
||||
if (!ReLotteryCheck(cardID))
|
||||
{
|
||||
pathType = ResourcesManager.AssetLoadPathType.UnitCardTextures;
|
||||
switch (cardParameterFromId.CharType)
|
||||
{
|
||||
case CardBasePrm.CharaType.CLASS:
|
||||
case CardBasePrm.CharaType.EVOLUTION:
|
||||
continue;
|
||||
case CardBasePrm.CharaType.NORMAL:
|
||||
pathType = ResourcesManager.AssetLoadPathType.UnitCardTextures;
|
||||
break;
|
||||
case CardBasePrm.CharaType.SPELL:
|
||||
pathType = ResourcesManager.AssetLoadPathType.SpellCardTextures;
|
||||
break;
|
||||
case CardBasePrm.CharaType.FIELD:
|
||||
case CardBasePrm.CharaType.CHANT_FIELD:
|
||||
pathType = ResourcesManager.AssetLoadPathType.SpellCardTextures;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
ResourcesManager resMgr = Toolbox.ResourcesManager;
|
||||
LoadingTextObj.labels[0].text = cardParameterFromId.CardName;
|
||||
LoadingTextObj.labels[1].SetWrapText(cardParameterFromId.Description);
|
||||
resourcePathList = new List<string>
|
||||
{
|
||||
resMgr.GetAssetTypePath(cardID.ToString(), pathType),
|
||||
resMgr.GetAssetTypePath("class_base_common", ResourcesManager.AssetLoadPathType.ClassCharaMaterialMain),
|
||||
resMgr.GetAssetTypePath("loading_battle_mask", ResourcesManager.AssetLoadPathType.UiOtherTexture)
|
||||
};
|
||||
yield return StartCoroutine(resMgr.LoadAssetGroupAsync(resourcePathList, null));
|
||||
Texture value = resMgr.LoadObject<Texture>(resMgr.GetAssetTypePath(cardID + "0", pathType, isfetch: true));
|
||||
Texture value2 = resMgr.LoadObject<Texture>(resMgr.GetAssetTypePath("loading_battle_mask", ResourcesManager.AssetLoadPathType.UiOtherTexture, isfetch: true));
|
||||
LoadingTextObj.textures[0].mainTexture = null;
|
||||
LoadingTextObj.textures[0].material = resMgr.LoadObject<Material>(resMgr.GetAssetTypePath("class_base_common", ResourcesManager.AssetLoadPathType.ClassCharaMaterialMain, isfetch: true));
|
||||
LoadingTextObj.textures[0].material.SetTexture("_MainTex", value);
|
||||
LoadingTextObj.textures[0].material.SetTexture("_MaskTex", value2);
|
||||
LoadingTextObj.textures[0].gameObject.SetActive(value: false);
|
||||
LoadingTextObj.textures[0].gameObject.SetActive(value: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = UnityEngine.Random.Range(1, LoadingTipsIndexMax + 1);
|
||||
LoadingTextObj.labels[0].SetWrapText(Data.SystemText.Get(string.Format("{0}{1}", "Load_Title", num.ToString("0000"))));
|
||||
LoadingTextObj.labels[1].SetWrapText(Data.SystemText.Get(string.Format("{0}{1}", "Load_Desc", num.ToString("0000"))));
|
||||
}
|
||||
}
|
||||
|
||||
private bool ReLotteryCheck(int id)
|
||||
{
|
||||
if (CardMaster.GetInstanceForBattle().GetCardParameterFromId(id).ResourceCardId != id || Data.Load.data.LoadingExclusionCardList.Contains(id) || CardMaster.IsMutationCardCheck(id) || (id > 800000000 && id % 800000000 < 100000000) || CardMaster.IsChoiceBraveCardCheck(id))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if ((bool)Anchor && !Anchor.gameObject.activeSelf)
|
||||
{
|
||||
Anchor.enabled = true;
|
||||
Anchor.gameObject.SetActive(value: true);
|
||||
}
|
||||
}
|
||||
|
||||
private void StartLoadingTextAnimation(string overrideLoadingText = null)
|
||||
{
|
||||
string loadingText = ((overrideLoadingText != null) ? overrideLoadingText : ((!Matching) ? Data.SystemText.Get("System_0001") : Data.SystemText.Get("Battle_0008")));
|
||||
StopLoadingTextAnimation();
|
||||
_coroutineTextAnimation = StartCoroutine(LoadingTextAnimation(loadingText));
|
||||
}
|
||||
|
||||
private void StopLoadingTextAnimation()
|
||||
{
|
||||
if (_coroutineTextAnimation != null)
|
||||
{
|
||||
StopCoroutine(_coroutineTextAnimation);
|
||||
_coroutineTextAnimation = null;
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator LoadingTextAnimation(string loadingText)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if ((bool)LoadingLabel)
|
||||
{
|
||||
LoadingLabel.text = loadingText;
|
||||
DotCnt++;
|
||||
if (DotCnt > 3)
|
||||
{
|
||||
DotCnt = 0;
|
||||
}
|
||||
if (LoadingCountLabel != null)
|
||||
{
|
||||
LoadingCountLabel.text = "";
|
||||
}
|
||||
for (int i = 0; i < DotCnt; i++)
|
||||
{
|
||||
if (LoadingCountLabel != null)
|
||||
{
|
||||
LoadingCountLabel.text += ".";
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadingLabel.text += ".";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (notText)
|
||||
{
|
||||
if (LoadingLabel != null)
|
||||
{
|
||||
LoadingLabel.text = "";
|
||||
}
|
||||
if (LoadingCountLabel != null)
|
||||
{
|
||||
LoadingCountLabel.text = "";
|
||||
}
|
||||
}
|
||||
yield return new WaitForSeconds(0.05f);
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeIn(bool notBlack = false, bool notCollider = false, float alphe = 1f, float panelFadeInDuration = 0.5f, string overrideText = null)
|
||||
{
|
||||
StartCoroutine(FadeInAndLoad(notBlack, notCollider, alphe, panelFadeInDuration));
|
||||
StartLoadingTextAnimation(overrideText);
|
||||
}
|
||||
|
||||
private IEnumerator FadeInAndLoad(bool notBlack = false, bool notCollider = false, float alphe = 1f, float panelFadeInDuration = 0.5f)
|
||||
{
|
||||
if (notCollider)
|
||||
{
|
||||
GetComponent<BoxCollider>().enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GetComponent<BoxCollider>().enabled = true;
|
||||
}
|
||||
if ((bool)Anchor)
|
||||
{
|
||||
Anchor.gameObject.SetActive(value: false);
|
||||
}
|
||||
StartFadeInUI(panelFadeInDuration);
|
||||
CancelInvoke("HideObj");
|
||||
IsFadeout = false;
|
||||
GameObject bgObj = base.transform.Find("Bg").gameObject;
|
||||
if (notBlack)
|
||||
{
|
||||
bgObj.SetActive(value: false);
|
||||
yield break;
|
||||
}
|
||||
if (LoadingTextObj != null)
|
||||
{
|
||||
yield return StartCoroutine(SetLoadingText());
|
||||
}
|
||||
bgObj.SetActive(value: true);
|
||||
bgObj.GetComponent<UISprite>().color = new Color(0f, 0f, 0f, alphe);
|
||||
if (null != BGTexture)
|
||||
{
|
||||
BGTexture.alpha = 0f;
|
||||
TweenAlpha.Begin(BGTexture.gameObject, 0.5f, 1f);
|
||||
}
|
||||
}
|
||||
|
||||
public void FadeOut(bool disableCollider = false)
|
||||
{
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
num = 1;
|
||||
if (null != BGTexture)
|
||||
{
|
||||
TweenAlpha.Begin(BGTexture.gameObject, 0.25f, 0f);
|
||||
}
|
||||
num = 2;
|
||||
StartFadeOutUI();
|
||||
num = 3;
|
||||
Invoke("HideObj", 0.5f);
|
||||
num = 4;
|
||||
IsFadeout = true;
|
||||
if (disableCollider)
|
||||
{
|
||||
GetComponent<BoxCollider>().enabled = false;
|
||||
}
|
||||
num = 5;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string text = "";
|
||||
if (base.gameObject == null)
|
||||
{
|
||||
text += "obj null ";
|
||||
}
|
||||
if (BGTexture == null)
|
||||
{
|
||||
text += "BGTexture null ";
|
||||
}
|
||||
else if (BGTexture.gameObject == null)
|
||||
{
|
||||
text += "BGTextureObj null ";
|
||||
}
|
||||
LocalLog.AccumulateTraceLog("#580304 FadeOut " + num + " disableCollider " + disableCollider + text);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
private void StartFadeInUI(float panelFadeInDuration = 0.5f)
|
||||
{
|
||||
if (_fadeBlackPanel != null)
|
||||
{
|
||||
_fadeBlackPanel.alpha = 1f;
|
||||
TweenAlpha.Begin(_fadeBlackPanel.gameObject, panelFadeInDuration, 0f);
|
||||
return;
|
||||
}
|
||||
UIPanel component = GetComponent<UIPanel>();
|
||||
if ((bool)component)
|
||||
{
|
||||
component.alpha = 0.01f;
|
||||
}
|
||||
TweenAlpha.Begin(base.gameObject, panelFadeInDuration, 1f);
|
||||
}
|
||||
|
||||
private void StartFadeOutUI(float panelFadeOutDuration = 0.5f)
|
||||
{
|
||||
if (_fadeBlackPanel != null)
|
||||
{
|
||||
_fadeBlackPanel.alpha = 0f;
|
||||
TweenAlpha.Begin(_fadeBlackPanel.gameObject, panelFadeOutDuration, 1f);
|
||||
}
|
||||
else
|
||||
{
|
||||
TweenAlpha.Begin(base.gameObject, panelFadeOutDuration, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
private void HideObj()
|
||||
{
|
||||
int num = 0;
|
||||
try
|
||||
{
|
||||
num = 1;
|
||||
StopLoadingTextAnimation();
|
||||
num = 2;
|
||||
if (cardMask != null)
|
||||
{
|
||||
UnityEngine.Object.Destroy(cardMask);
|
||||
}
|
||||
num = 3;
|
||||
if (resourcePathList != null)
|
||||
{
|
||||
Toolbox.ResourcesManager.RemoveAssetGroup(resourcePathList);
|
||||
num = 4;
|
||||
resourcePathList.Clear();
|
||||
resourcePathList = null;
|
||||
}
|
||||
num = 5;
|
||||
base.gameObject.SetActive(value: false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
string text = "";
|
||||
if (base.gameObject == null)
|
||||
{
|
||||
text += "obj null ";
|
||||
}
|
||||
LocalLog.AccumulateTraceLog("#580304 HideObj " + num + text);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user