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>
402 lines
10 KiB
C#
402 lines
10 KiB
C#
using System.Linq;
|
|
using Cute;
|
|
using UnityEngine;
|
|
|
|
namespace Wizard;
|
|
|
|
public class CardListTemplate : MonoBehaviour
|
|
{
|
|
|
|
public static readonly Color RED_COLOR_NAME = new Color32(215, 142, 153, byte.MaxValue);
|
|
|
|
public static readonly Color RED_COLOR = new Color32(215, 142, 153, byte.MaxValue);
|
|
|
|
public static readonly Color RED_COLOR_EFFECT = new Color32(121, 0, 41, byte.MaxValue);
|
|
|
|
[SerializeField]
|
|
private GameObject _numRoot;
|
|
|
|
[SerializeField]
|
|
private GameObject _normalNumRoot;
|
|
|
|
[SerializeField]
|
|
private GameObject _favoriteNumRoot;
|
|
|
|
[SerializeField]
|
|
public UITexture _cardTexture;
|
|
|
|
[SerializeField]
|
|
public UIShaderSprite _frameSprite;
|
|
|
|
[SerializeField]
|
|
public UITexture _classIconTexture;
|
|
|
|
[SerializeField]
|
|
private UISprite _skillClassIconBossRush;
|
|
|
|
[SerializeField]
|
|
public UILabel _nameLabel;
|
|
|
|
[SerializeField]
|
|
public UILabel _atkLabel;
|
|
|
|
[SerializeField]
|
|
public UILabel _lifeLabel;
|
|
|
|
[SerializeField]
|
|
public UILabel _costLabel;
|
|
|
|
[SerializeField]
|
|
public UILabel _newLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _normalNumLabel;
|
|
|
|
[SerializeField]
|
|
private UILabel _favoriteNumLabel;
|
|
|
|
[SerializeField]
|
|
private UIShaderSprite _rotationOnlyIcon;
|
|
|
|
[SerializeField]
|
|
private GameObject _infoRoot;
|
|
|
|
private int _id;
|
|
|
|
private int _num;
|
|
|
|
private int _spotCardNum;
|
|
|
|
private bool _isShowingNormalNum;
|
|
|
|
private bool _isHidingNum;
|
|
|
|
private bool _isFaceUp;
|
|
|
|
private static Shader _grayShader = null;
|
|
|
|
private static Shader _redShader = null;
|
|
|
|
private static Shader _frameShader = null;
|
|
|
|
private static Shader _normalShader = null;
|
|
|
|
private static Shader _premiumShader = null;
|
|
|
|
private static Shader _graySpriteShader = null;
|
|
|
|
private static Shader _redSpriteShader = null;
|
|
|
|
private static Shader _spriteNormalShader = null;
|
|
|
|
private Material _duplicatedCardMaterial;
|
|
|
|
private UIWidget[] widgetList;
|
|
|
|
private bool _rotationIconVisible;
|
|
|
|
public bool IsIncludingSpotCard { get; set; }
|
|
|
|
public bool RotationOnlyIconVisible
|
|
{
|
|
set
|
|
{
|
|
_rotationIconVisible = value;
|
|
_rotationOnlyIcon.gameObject.SetActive(value);
|
|
}
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
_isShowingNormalNum = true;
|
|
_isHidingNum = false;
|
|
SetFace(isUp: true);
|
|
_numRoot.SetActive(!_isHidingNum);
|
|
_normalNumRoot.SetActive(_isShowingNormalNum);
|
|
_favoriteNumRoot.SetActive(!_isShowingNormalNum);
|
|
SetInfoVisible(visible: false);
|
|
_skillClassIconBossRush.gameObject.SetActive(value: false);
|
|
if (_spriteNormalShader == null)
|
|
{
|
|
_spriteNormalShader = Shader.Find("Unlit/JongTransparent Colored");
|
|
}
|
|
}
|
|
|
|
public void SetId(int id)
|
|
{
|
|
_id = id;
|
|
}
|
|
|
|
public void SetNum(int num, int spotCardNum = 0)
|
|
{
|
|
_num = num;
|
|
_spotCardNum = spotCardNum;
|
|
string text = (IsIncludingSpotCard ? $"{num}[fcd24a]+{spotCardNum}" : num.ToString());
|
|
UILabel normalNumLabel = _normalNumLabel;
|
|
string text2 = (_favoriteNumLabel.text = text);
|
|
normalNumLabel.text = text2;
|
|
if (!_isHidingNum && _isFaceUp)
|
|
{
|
|
if (_isShowingNormalNum /* Pre-Phase-5b: no favorites headless */)
|
|
{
|
|
_normalNumRoot.SetActive(value: true);
|
|
_favoriteNumRoot.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
_normalNumRoot.SetActive(value: false);
|
|
_favoriteNumRoot.SetActive(value: true);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int GetNum()
|
|
{
|
|
return _num;
|
|
}
|
|
|
|
public int GetSpotCardNum()
|
|
{
|
|
return _spotCardNum;
|
|
}
|
|
|
|
public void ShowNum()
|
|
{
|
|
_isHidingNum = false;
|
|
SetNum(_num, _spotCardNum);
|
|
}
|
|
|
|
public void HideNum()
|
|
{
|
|
_isHidingNum = true;
|
|
_normalNumRoot.SetActive(value: false);
|
|
_favoriteNumRoot.SetActive(value: false);
|
|
}
|
|
|
|
public void ChangeShowNumType(bool isNormal)
|
|
{
|
|
_isShowingNormalNum = isNormal;
|
|
SetNum(_num, _spotCardNum);
|
|
}
|
|
|
|
public bool IsShowNum()
|
|
{
|
|
return !_isHidingNum;
|
|
}
|
|
|
|
public void SetFace(bool isUp)
|
|
{
|
|
_isFaceUp = isUp;
|
|
_frameSprite.gameObject.SetActive(isUp);
|
|
_classIconTexture.gameObject.SetActive(isUp);
|
|
_atkLabel.gameObject.SetActive(isUp);
|
|
_lifeLabel.gameObject.SetActive(isUp);
|
|
_costLabel.gameObject.SetActive(isUp);
|
|
_rotationOnlyIcon.gameObject.SetActive(isUp && _rotationIconVisible);
|
|
if (isUp)
|
|
{
|
|
SetNum(_num, _spotCardNum);
|
|
return;
|
|
}
|
|
_normalNumRoot.SetActive(value: false);
|
|
_favoriteNumRoot.SetActive(value: false);
|
|
}
|
|
|
|
public void AttachNormalShaderRotationOnlyIcon()
|
|
{
|
|
_rotationOnlyIcon.SetShader(_spriteNormalShader);
|
|
}
|
|
|
|
public void AttachGrayShader()
|
|
{
|
|
if (_grayShader == null)
|
|
{
|
|
_grayShader = Shader.Find("Wizard/Card/GrayOut");
|
|
}
|
|
if (_graySpriteShader == null)
|
|
{
|
|
_graySpriteShader = Shader.Find("Wizard/Card/GrayOutSprite");
|
|
}
|
|
if (_cardTexture.material != null)
|
|
{
|
|
if (_duplicatedCardMaterial == null)
|
|
{
|
|
_duplicatedCardMaterial = new Material(_cardTexture.material);
|
|
}
|
|
_duplicatedCardMaterial.shader = _grayShader;
|
|
_cardTexture.material = _duplicatedCardMaterial;
|
|
}
|
|
_rotationOnlyIcon.SetShader(_graySpriteShader, isSharedMaterial: false);
|
|
_frameSprite.SetShader(_graySpriteShader);
|
|
_classIconTexture.shader = _grayShader;
|
|
_costLabel.effectColor = Color.gray;
|
|
_atkLabel.effectColor = Color.gray;
|
|
_lifeLabel.effectColor = Color.gray;
|
|
_costLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
_atkLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
_lifeLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
_nameLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
_newLabel.gameObject.SetActive(value: false);
|
|
_cardTexture.enabled = false;
|
|
_cardTexture.enabled = true;
|
|
}
|
|
|
|
public void AttachRedMaterial()
|
|
{
|
|
if (_redShader == null)
|
|
{
|
|
_redShader = Shader.Find("Wizard/Card/RedOut");
|
|
}
|
|
if (_redSpriteShader == null)
|
|
{
|
|
_redSpriteShader = Shader.Find("Wizard/Card/RedOutSprite");
|
|
}
|
|
if (_cardTexture.material != null)
|
|
{
|
|
if (_duplicatedCardMaterial == null)
|
|
{
|
|
_duplicatedCardMaterial = new Material(_cardTexture.material);
|
|
}
|
|
_duplicatedCardMaterial.shader = _redShader;
|
|
_cardTexture.material = _duplicatedCardMaterial;
|
|
}
|
|
_rotationOnlyIcon.SetShader(_redSpriteShader);
|
|
_frameSprite.SetShader(_redSpriteShader);
|
|
_classIconTexture.shader = _redShader;
|
|
_costLabel.effectColor = RED_COLOR_EFFECT;
|
|
_atkLabel.effectColor = RED_COLOR_EFFECT;
|
|
_lifeLabel.effectColor = RED_COLOR_EFFECT;
|
|
_costLabel.color = RED_COLOR;
|
|
_atkLabel.color = RED_COLOR;
|
|
_lifeLabel.color = RED_COLOR;
|
|
_nameLabel.color = RED_COLOR_NAME;
|
|
_cardTexture.enabled = false;
|
|
_cardTexture.enabled = true;
|
|
}
|
|
|
|
public void AttachShaders(CardMaster.CardMasterId cardMasterId)
|
|
{
|
|
CardParameter cardParameterFromId = CardMaster.GetInstance(cardMasterId).GetCardParameterFromId(_id);
|
|
ResourcesManager.AssetLoadPathType type = ResourcesManager.AssetLoadPathType.UnitCardMaterial;
|
|
if (cardParameterFromId.CharType != CardBasePrm.CharaType.NORMAL && !CardMaster.IsMutationCardCheck(cardParameterFromId.BaseCardId))
|
|
{
|
|
type = ResourcesManager.AssetLoadPathType.SpellCardMaterial;
|
|
}
|
|
if (_cardTexture.material == null)
|
|
{
|
|
_cardTexture.material = Toolbox.ResourcesManager.FindCardMaterial(cardParameterFromId.ResourceCardId, type);
|
|
}
|
|
if (_cardTexture.material != null)
|
|
{
|
|
if (cardParameterFromId.IsFoil)
|
|
{
|
|
if (_premiumShader == null)
|
|
{
|
|
_premiumShader = Shader.Find("Wizard/VariantCardShader");
|
|
}
|
|
_cardTexture.material.shader = _premiumShader;
|
|
}
|
|
else
|
|
{
|
|
if (_normalShader == null)
|
|
{
|
|
_normalShader = Shader.Find("Wizard/Card/Basic_Front0_Back0_Normal");
|
|
}
|
|
_cardTexture.material.shader = _normalShader;
|
|
}
|
|
_cardTexture.material.color = Color.white;
|
|
}
|
|
AttachNormalFrame(cardParameterFromId);
|
|
_rotationOnlyIcon.SetShader(_spriteNormalShader);
|
|
_cardTexture.enabled = false;
|
|
_cardTexture.enabled = true;
|
|
}
|
|
|
|
public void AttachNormalFrame(CardParameter param)
|
|
{
|
|
if (_frameShader == null)
|
|
{
|
|
_frameShader = Shader.Find("Unlit/Transparent Colored");
|
|
}
|
|
if (_frameSprite.shader != _frameSprite.atlas?.spriteMaterial.shader)
|
|
{
|
|
_frameSprite.SetShader(null);
|
|
}
|
|
if (_classIconTexture.shader != _frameShader)
|
|
{
|
|
_classIconTexture.shader = _frameShader;
|
|
}
|
|
_classIconTexture.mainTexture = ClassCharaPrm.GetClassIconTexture((int)param.Clan);
|
|
_costLabel.effectColor = Global.CARD_LABEL_FRAME_COST_COLOR;
|
|
_atkLabel.effectColor = Global.CARD_LABEL_FRAME_ATTACK_COLOR;
|
|
_lifeLabel.effectColor = Global.CARD_LABEL_FRAME_HEALTH_COLOR;
|
|
_costLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
_atkLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
_lifeLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
_nameLabel.color = Global.CARD_LABEL_FRAME_TEXT_COLOR;
|
|
}
|
|
|
|
public void SetInfoVisible(bool visible)
|
|
{
|
|
_infoRoot.SetActive(visible);
|
|
}
|
|
|
|
public void SetFrame(CardParameter cardParam)
|
|
{
|
|
string arg = string.Empty;
|
|
if (cardParam.IsPhantomCard)
|
|
{
|
|
arg = "_phantom";
|
|
_frameSprite.atlas = null;
|
|
}
|
|
string spriteName = string.Empty;
|
|
int num = cardParam.Rarity - 1;
|
|
switch (cardParam.CharType)
|
|
{
|
|
case CardBasePrm.CharaType.NORMAL:
|
|
spriteName = $"frame_card_unit_{num:D2}{arg}";
|
|
break;
|
|
case CardBasePrm.CharaType.SPELL:
|
|
spriteName = $"frame_card_spell_{num:D2}{arg}";
|
|
break;
|
|
case CardBasePrm.CharaType.FIELD:
|
|
case CardBasePrm.CharaType.CHANT_FIELD:
|
|
spriteName = $"frame_card_field_{num:D2}{arg}";
|
|
break;
|
|
}
|
|
_frameSprite.spriteName = spriteName;
|
|
UIManager.GetInstance().AttachAtlas(_frameSprite.gameObject);
|
|
}
|
|
|
|
public void SetParentAndResetPos(Transform parent)
|
|
{
|
|
base.transform.parent = parent;
|
|
base.transform.localPosition = Vector3.zero;
|
|
}
|
|
|
|
public void SetScale(float scale)
|
|
{
|
|
base.transform.localScale = new Vector3(scale, scale, 1f);
|
|
}
|
|
|
|
public void AddDepth(int addValue)
|
|
{
|
|
if (widgetList == null)
|
|
{
|
|
widgetList = base.gameObject.GetComponentsInChildren<UIWidget>(includeInactive: true);
|
|
}
|
|
UIWidget[] array = widgetList;
|
|
for (int i = 0; i < array.Length; i++)
|
|
{
|
|
array[i].depth += addValue;
|
|
}
|
|
}
|
|
|
|
public UIEventListener AddColliderToFrame(float scale = 1f)
|
|
{
|
|
GameObject obj = _frameSprite.gameObject;
|
|
obj.AddComponent<BoxCollider>().size = _frameSprite.localSize * scale;
|
|
return UIEventListener.Get(obj);
|
|
}
|
|
}
|