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

@@ -6,21 +6,6 @@ namespace Wizard;
public class CardListTemplate : MonoBehaviour
{
public static readonly Color NORMAL_COLOR_COST_LABEL_OUTLINE = new Color32(20, 71, 0, byte.MaxValue);
public static readonly Color DARK_COLOR_COST_LABEL_OUTLINE = new Color32(7, 24, 0, byte.MaxValue);
public static readonly Color NORMAL_COLOR_ATK_LABEL_OUTLINE = new Color32(0, 16, 96, byte.MaxValue);
public static readonly Color DARK_COLOR_ATK_LABEL_OUTLINE = new Color32(0, 5, 32, byte.MaxValue);
public static readonly Color NORMAL_COLOR_LIFE_LABEL_OUTLINE = new Color32(88, 0, 0, byte.MaxValue);
public static readonly Color DARK_COLOR_LIFE_LABEL_OUTLINE = new Color32(29, 0, 0, byte.MaxValue);
public static readonly Color NORMAL_COLOR_PREMIRE_CARD_NAME_OUTLINE = new Color32(92, 56, 3, byte.MaxValue);
public static readonly Color DARK_COLOR_PREMIRE_CARD_NAME_OUTLINE = new Color32(31, 19, 1, byte.MaxValue);
public static readonly Color RED_COLOR_NAME = new Color32(215, 142, 153, byte.MaxValue);
@@ -28,32 +13,6 @@ public class CardListTemplate : MonoBehaviour
public static readonly Color RED_COLOR_EFFECT = new Color32(121, 0, 41, byte.MaxValue);
private const string SHADER_NAME_DEFAULT = "Unlit/Transparent Colored";
private const string SHADER_NAME_GRAY = "Wizard/Card/GrayOut";
private const string SHADER_NAME_RED = "Wizard/Card/RedOut";
private const string SHADER_NAME_GRAY_SPRITE = "Wizard/Card/GrayOutSprite";
private const string SHADER_NAME_RED_SPRITE = "Wizard/Card/RedOutSprite";
private const string SPRITE_NORMAL_SHADER = "Unlit/JongTransparent Colored";
private const string FRAME_SPRITE_NAME_FORMAT_FOLLOWER = "frame_card_unit_{0:D2}{1}";
private const string FRAME_SPRITE_NAME_FORMAT_SPELL = "frame_card_spell_{0:D2}{1}";
private const string FRAME_SPRITE_NAME_FORMAT_AMULET = "frame_card_field_{0:D2}{1}";
private const string FRAME_SPRITE_NAME_SUFFIX_PHANTOM = "_phantom";
private const string FRAME_SKILL_NAME = "frame_skill";
public const string SPOT_CARD_COLOR_TEXT = "[fcd24a]";
public const string SPOT_CARD_TEXT_FORMAT = "{0}[fcd24a]+{1}";
[SerializeField]
private GameObject _numRoot;
@@ -102,9 +61,6 @@ public class CardListTemplate : MonoBehaviour
[SerializeField]
private GameObject _infoRoot;
[SerializeField]
private UILabel _infoLabel;
private int _id;
private int _num;
@@ -171,11 +127,6 @@ public class CardListTemplate : MonoBehaviour
_id = id;
}
public int GetId()
{
return _id;
}
public void SetNum(int num, int spotCardNum = 0)
{
_num = num;
@@ -186,7 +137,7 @@ public class CardListTemplate : MonoBehaviour
normalNumLabel.text = text2;
if (!_isHidingNum && _isFaceUp)
{
if (_isShowingNormalNum || !GameMgr.GetIns().GetDataMgr().FavoriteCardList.Contains(_id))
if (_isShowingNormalNum /* Pre-Phase-5b: no favorites headless */)
{
_normalNumRoot.SetActive(value: true);
_favoriteNumRoot.SetActive(value: false);
@@ -222,15 +173,6 @@ public class CardListTemplate : MonoBehaviour
_favoriteNumRoot.SetActive(value: false);
}
public void HideLabelsForBossRushSkill()
{
_nameLabel.gameObject.SetActive(value: false);
_atkLabel.gameObject.SetActive(value: false);
_lifeLabel.gameObject.SetActive(value: false);
_costLabel.gameObject.SetActive(value: false);
_newLabel.gameObject.SetActive(value: false);
}
public void ChangeShowNumType(bool isNormal)
{
_isShowingNormalNum = isNormal;
@@ -260,36 +202,6 @@ public class CardListTemplate : MonoBehaviour
_favoriteNumRoot.SetActive(value: false);
}
private void RemoveDuplicatedCardMaterial()
{
if (_duplicatedCardMaterial != null)
{
Object.Destroy(_duplicatedCardMaterial);
_duplicatedCardMaterial = null;
}
}
private void OnDestroy()
{
RemoveDuplicatedCardMaterial();
}
public void AttachCardTexture(Texture texture)
{
_cardTexture.mainTexture = texture;
if (_cardTexture.material != null)
{
if (_duplicatedCardMaterial == null)
{
_duplicatedCardMaterial = new Material(_cardTexture.material);
}
_duplicatedCardMaterial.mainTexture = texture;
_cardTexture.material = _duplicatedCardMaterial;
}
_cardTexture.enabled = false;
_cardTexture.enabled = true;
}
public void AttachNormalShaderRotationOnlyIcon()
{
_rotationOnlyIcon.SetShader(_spriteNormalShader);
@@ -429,16 +341,6 @@ public class CardListTemplate : MonoBehaviour
_infoRoot.SetActive(visible);
}
public void SetInfoLabelText(string text)
{
_infoLabel.text = text;
}
public void SetInfoLabelTextColor(Color color)
{
_infoLabel.color = color;
}
public void SetFrame(CardParameter cardParam)
{
string arg = string.Empty;
@@ -466,30 +368,6 @@ public class CardListTemplate : MonoBehaviour
UIManager.GetInstance().AttachAtlas(_frameSprite.gameObject);
}
public void SetBossRushSkillFrame()
{
UIAtlas atlas = UIManager.GetInstance().GetAtlasList().FirstOrDefault((UIAtlas s) => s.name == "BossRush");
_frameSprite.spriteName = "frame_skill";
_frameSprite.atlas = atlas;
_classIconTexture.gameObject.SetActive(value: false);
CardParameter cardParameterFromId = CardMaster.GetInstance(CardMaster.CardMasterId.Default).GetCardParameterFromId(_id);
_skillClassIconBossRush.atlas = atlas;
_skillClassIconBossRush.spriteName = "class_skill_" + ((int)cardParameterFromId.Clan).ToString("00");
_skillClassIconBossRush.gameObject.SetActive(value: true);
}
public void SetBossRushIconSprite(string spriteName)
{
_skillClassIconBossRush.spriteName = spriteName;
}
public void SetBossRushCardTexture()
{
_cardTexture.uvRect = new Rect(0f, 0f, 1f, 1f);
_cardTexture.height = 207;
_cardTexture.transform.localPosition = new Vector3(_cardTexture.transform.localPosition.x, -10.5f, _cardTexture.transform.localPosition.z);
}
public void SetParentAndResetPos(Transform parent)
{
base.transform.parent = parent;
@@ -520,24 +398,4 @@ public class CardListTemplate : MonoBehaviour
obj.AddComponent<BoxCollider>().size = _frameSprite.localSize * scale;
return UIEventListener.Get(obj);
}
public void HideNewLabel()
{
_newLabel.gameObject.SetActive(value: false);
}
public void SetNewLabelPos(Vector3 pos)
{
_newLabel.transform.localPosition = pos;
}
public void ReplaceMaterialToTexture()
{
Material material = _cardTexture.material;
if (material != null)
{
_cardTexture.mainTexture = material.mainTexture;
_cardTexture.material = null;
}
}
}