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

@@ -9,16 +9,12 @@ public class InputMgr
NONE,
PRESS,
DOWN,
UP,
STAY,
MAX
}
UP}
public enum LAYER_TYPE
{
NONE = 0,
UI = 32,
PARTICLE = 256,
GAME = 512,
ALL = 65535
}
@@ -26,8 +22,6 @@ public class InputMgr
private enum ClickState
{
None,
Down,
LongPress,
UpThisFrame,
DownMoved
}
@@ -35,15 +29,9 @@ public class InputMgr
private enum DoubleClickState
{
None,
FirstClickDown,
SecondClickDown,
SecondClickUp
}
private const float FLICK_SEC = 0.2f;
private const string CHOICE_BUTTON_TAG = "ChoiceSelectButton";
private Vector2 m_NonePos = new Vector2(-10000f, -10000f);
private IList<TYPE> m_NowTypeList = new List<TYPE>();
@@ -64,50 +52,18 @@ public class InputMgr
private IList<GameObject> m_DragEfcList = new List<GameObject>();
private bool _isInputEnable = true;
private bool _isBackKeyEnable = true;
public BattleCamera m_BattleCamera;
public BackGroundBase m_BackGround;
private bool _wentOverDrag;
public static bool MouseControl;
public static bool KeyboardControl;
public static bool KeyboardControlSpace;
public static bool KeyboardControlEvolution;
public bool KeyboardEnableControlSpace = true;
public float _lastFirstClick;
private DoubleClickState _doubleClick;
private Vector2 _firstClickPosition;
private const float DOUBLE_CLICK_TIME = 0.5f;
private float _timeSincePress;
private Vector2 _downPositionStart;
private const float LONG_PRESS_TIME = 0.3f;
private const float LONG_PRESS_THRESHOLD = 100f;
private ClickState _clickState;
public const int MOUSE_SHORTCUT_RIGHT_CLICK = 1;
public const int MOUSE_SHORTCUT_DOUBLE_CLICK = 2;
private float _KeyboardEmotionWaitTime;
public bool isBackKeyEnable
{
get
@@ -152,341 +108,11 @@ public class InputMgr
MouseControl = PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.MOUSE_CONTROL);
}
~InputMgr()
{
}
public void Update()
{
for (int i = 0; i < 1; i++)
{
m_NowTypeList[i] = TYPE.NONE;
}
if (_isInputEnable)
{
MouseClick();
CheckFlick();
}
}
private void CheckFlick()
{
m_IsFlick = false;
if (IsUp())
{
if (m_DraggingSec < 0.2f && 30f < Mathf.Abs(GetVec().x))
{
m_IsFlick = true;
}
m_DraggingSec = 0f;
}
if (IsPress())
{
m_DraggingSec += Time.deltaTime;
}
}
public void SetInputEnable(bool isEnable)
{
_isInputEnable = isEnable;
StopDragEffect();
}
private void StopDragEffect()
{
GameMgr.GetIns().GetEffectMgr().FadeStop(m_DragEfcList[0]);
}
private void MouseClick()
{
m_NowPosList[0] = Input.mousePosition;
m_FixedPosList[0] = ToolboxGame.UIManager.UIRootLoadingCamera.ScreenToWorldPoint(m_NowPosList[0]);
if (MouseControl)
{
if (_lastFirstClick > 0f && !Input.GetMouseButtonDown(0))
{
if (_firstClickPosition != m_NowPosList[0])
{
_lastFirstClick = 0f;
_doubleClick = DoubleClickState.None;
}
else
{
_lastFirstClick -= Time.deltaTime;
}
}
if (_doubleClick == DoubleClickState.SecondClickUp)
{
_doubleClick = DoubleClickState.None;
}
else if (_doubleClick == DoubleClickState.SecondClickDown && (_lastFirstClick <= 0f || _firstClickPosition != m_NowPosList[0]))
{
_doubleClick = DoubleClickState.None;
}
if (_clickState == ClickState.UpThisFrame)
{
_clickState = ClickState.None;
}
switch (_clickState)
{
case ClickState.None:
if (Input.GetMouseButtonDown(0))
{
_timeSincePress = 0f;
_downPositionStart = m_NowPosList[0];
_clickState = ClickState.Down;
if (Input.GetMouseButtonUp(0))
{
_clickState = ClickState.UpThisFrame;
}
}
break;
case ClickState.Down:
if (Input.GetMouseButtonUp(0))
{
_clickState = ClickState.UpThisFrame;
}
else if (Input.GetMouseButton(0))
{
if (IsInThreshold())
{
_timeSincePress += Time.unscaledDeltaTime;
if (_timeSincePress >= 0.3f)
{
_clickState = ClickState.LongPress;
}
}
else
{
_clickState = ClickState.DownMoved;
}
}
else
{
_clickState = ClickState.None;
}
break;
case ClickState.LongPress:
if (!Input.GetMouseButton(0))
{
_clickState = ClickState.None;
}
else if (!IsInThreshold())
{
_clickState = ClickState.DownMoved;
}
break;
case ClickState.DownMoved:
if (!Input.GetMouseButton(0))
{
_clickState = ClickState.None;
}
break;
}
}
if (Input.GetMouseButtonDown(0))
{
if (MouseControl)
{
if (_doubleClick == DoubleClickState.FirstClickDown && _lastFirstClick > 0f)
{
_doubleClick = DoubleClickState.SecondClickDown;
if (Input.GetMouseButtonUp(0))
{
_doubleClick = DoubleClickState.SecondClickUp;
}
}
else
{
_doubleClick = DoubleClickState.FirstClickDown;
_lastFirstClick = 0.5f;
_firstClickPosition = m_NowPosList[0];
m_FirstPosList[0] = m_NowPosList[0];
m_NowTypeList[0] = TYPE.DOWN;
CheckTouchObject(0);
}
}
else
{
m_FirstPosList[0] = m_NowPosList[0];
m_NowTypeList[0] = TYPE.DOWN;
CheckTouchObject(0);
}
}
else if (Input.GetMouseButtonUp(0))
{
m_EndPosList[0] = m_NowPosList[0];
m_NowTypeList[0] = TYPE.UP;
if (_doubleClick == DoubleClickState.SecondClickDown)
{
_doubleClick = DoubleClickState.SecondClickUp;
_lastFirstClick = 0f;
}
}
else if (Input.GetMouseButton(0))
{
m_NowTypeList[0] = TYPE.PRESS;
if (m_DragEfcList[0] != null)
{
m_DragEfcList[0].transform.position = m_FixedPosList[0];
}
}
else
{
StopDragEffect();
}
if (m_NowTypeList[0] != TYPE.NONE && IsLayerMask())
{
m_NowTypeList[0] = TYPE.NONE;
}
}
public void SetBattleCamera(BattleCamera battleCamera)
{
m_BattleCamera = battleCamera;
}
public void SetBackGround(BackGroundBase backGround)
{
m_BackGround = backGround;
}
private void CheckTouchObject(int touchId)
{
Ray ray;
if (!ToolboxGame.UIManager.IsCurrentScene(UIManager.ViewScene.Battle))
{
ray = ToolboxGame.UIManager.UIRootLoadingCamera.ScreenPointToRay(m_NowPosList[touchId]);
}
else
{
if (BattleManagerBase.GetIns() == null || m_BattleCamera == null || m_BattleCamera.Get3DCamera() == null)
{
return;
}
ray = m_BattleCamera.Get3DCamera().ScreenPointToRay(m_NowPosList[touchId]);
}
RaycastHit hitInfo = default(RaycastHit);
if (ToolboxGame.UIManager.IsCurrentScene(UIManager.ViewScene.Battle))
{
bool flag = false;
bool flag2 = false;
if (TouchControl.CastRayWithTags(m_NowPosList[touchId], new List<string> { "BattleUI", "ChoiceSelectButton" }))
{
flag = true;
}
else
{
RaycastHit[] array = Physics.RaycastAll(ray.origin, ray.direction, float.PositiveInfinity);
float num = float.PositiveInfinity;
float num2 = float.PositiveInfinity;
Collider collider = null;
Collider collider2 = null;
for (int i = 0; i < array.Length; i++)
{
float distance = array[i].distance;
if (distance < num)
{
num = distance;
collider = array[i].collider;
}
switch (array[i].collider.tag)
{
case "Player":
case "Enemy":
case "PlayerToken":
case "EnemyToken":
case "DetailPanel":
case "ClassBtn":
case "CardHolder":
case "ECardHolder":
case "EpPanel":
flag = true;
break;
case "Detail":
{
int layer = array[i].collider.gameObject.layer;
if (UIManager.GetInstance().GetCurrentScene() != UIManager.ViewScene.Battle)
{
if (layer == 14)
{
flag2 = true;
}
}
else if (layer == 14)
{
flag = true;
}
break;
}
case "Untappable":
if (distance < num2)
{
num2 = distance;
collider2 = array[i].collider;
}
break;
}
}
if (collider == collider2)
{
return;
}
}
if (flag2)
{
Transform transform = GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_INPUT_TOUCH_2, m_FixedPosList[touchId].x, m_FixedPosList[touchId].y)
.transform;
UIManager.GetInstance().SetLayerRecursive(transform, 14);
}
else if (flag)
{
Transform transform2 = GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_INPUT_TOUCH_2, m_FixedPosList[touchId].x, m_FixedPosList[touchId].y)
.transform;
UIManager.GetInstance().SetLayerRecursive(transform2, 22);
}
}
else if (Physics.Raycast(ray.origin, ray.direction, out hitInfo, float.PositiveInfinity))
{
Transform transform3 = GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_INPUT_TOUCH_2, m_FixedPosList[touchId].x, m_FixedPosList[touchId].y)
.transform;
UIManager.GetInstance().SetLayerRecursive(transform3, 22);
}
else
{
GameMgr.GetIns().GetEffectMgr().Start(EffectMgr.EffectType.CMN_INPUT_TOUCH_1, m_FixedPosList[touchId].x, m_FixedPosList[touchId].y);
}
if (m_DragEfcList[touchId] == null)
{
if (GameMgr.GetIns().GetEffectMgr().IsPreInEffectReady)
{
m_DragEfcList[touchId] = GameMgr.GetIns().GetEffectMgr().StartTouchEffect(EffectMgr.EffectType.CMN_INPUT_DRAG_1, m_FixedPosList[touchId].x, m_FixedPosList[touchId].y)
.GetGameObjIns();
}
}
else
{
GameMgr.GetIns().GetEffectMgr().FadePlay(m_DragEfcList[touchId], m_FixedPosList[touchId].x, m_FixedPosList[touchId].y);
}
}
private bool IsLayerMask()
{
if (m_LayerMask == 0)
{
return false;
}
if (m_NowTypeList[0] != TYPE.DOWN)
{
return false;
}
if (Physics2D.GetRayIntersection(ToolboxGame.UIManager.UIRootLoadingCamera.ScreenPointToRay(m_NowPosList[0]), float.PositiveInfinity, m_LayerMask).collider != null)
{
return true;
}
return false;
}
public bool IsNone()
{
if (m_NowTypeList[0] == TYPE.NONE)
@@ -523,79 +149,21 @@ public class InputMgr
return false;
}
public bool IsStay()
{
if (m_NowTypeList[0] == TYPE.STAY)
{
return true;
}
return false;
}
public void InitLayerMask()
{
m_LayerMask = 0;
}
public void SetLayerMask(int LayerMask)
{
m_LayerMask = LayerMask;
}
public Vector2 GetFirstPos()
{
return m_FirstPosList[0];
}
public Vector2 GetEndPos()
{
return m_EndPosList[0];
}
public Vector2 GetPos()
{
return m_NowPosList[0];
}
public Vector2 GetFixedPos()
{
if (m_NowTypeList[0] == TYPE.NONE)
{
return m_NonePos;
}
return m_FixedPosList[0];
}
public Vector2 GetVec()
{
return m_NowPosList[0] - m_FirstPosList[0];
}
public float GetAngle()
{
return Mathf.Atan2(m_FirstPosList[0].y - m_NowPosList[0].y, m_FirstPosList[0].x - m_NowPosList[0].x) * 57.29578f + 180f;
}
public bool IsFlick()
{
return m_IsFlick;
}
public Vector2 GetFlickVec()
{
return GetVec();
}
public bool IsDoubleClick()
{
return _doubleClick == DoubleClickState.SecondClickUp;
}
public bool IsLongPress()
{
return _clickState == ClickState.LongPress;
}
public bool IsClick()
{
return _clickState == ClickState.UpThisFrame;
@@ -606,196 +174,8 @@ public class InputMgr
return _clickState == ClickState.DownMoved;
}
private bool IsInThreshold()
{
return (_downPositionStart - m_NowPosList[0]).sqrMagnitude <= 100f;
}
public bool IsOverDragDistanceHandPlay(Vector2? firstPosition = null)
{
if (!firstPosition.HasValue)
{
firstPosition = GetFirstPos();
}
bool flag = !(GetPos().y - firstPosition.Value.y < 40f);
_wentOverDrag |= flag;
return flag;
}
public bool IsOverDragDistanceInPlay()
{
if (!(Mathf.Abs(GetPos().y - GetFirstPos().y) > 40f))
{
return Mathf.Abs(GetPos().x - GetFirstPos().x) > 40f;
}
return true;
}
public bool IsOverDragDistanceMulligan()
{
return Vector2.Distance(GetPos(), GetFirstPos()) > 40f;
}
public bool IsKeyboardUpArrow()
{
if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
{
return true;
}
return false;
}
public bool IsKeyboardDownArrow()
{
if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
{
return true;
}
return false;
}
public bool IsKeyboardRightArrow()
{
if (Input.GetKeyDown(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow))
{
return true;
}
return false;
}
public bool IsKeyboardLeftArrow()
{
if (Input.GetKeyDown(KeyCode.A) || Input.GetKeyDown(KeyCode.LeftArrow))
{
return true;
}
return false;
}
public bool IsKeyboardEnter()
{
if (Input.GetKeyDown(KeyCode.Q) || Input.GetKeyDown(KeyCode.Return))
{
return true;
}
return false;
}
public bool IsKeyboardSpace()
{
if (Input.GetKeyDown(KeyCode.Space))
{
return true;
}
return false;
}
public bool IsKeyboardShift()
{
if (Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift))
{
return true;
}
return false;
}
public bool IsKeyboardCancel()
{
if (Input.GetKeyDown(KeyCode.Backspace) || Input.GetKeyDown(KeyCode.C))
{
return true;
}
return false;
}
public bool IsKeyboardEvolve()
{
if (Input.GetKeyDown(KeyCode.E))
{
return true;
}
return false;
}
public void SetKeyboardEmotionWaitTime(float wait)
{
_KeyboardEmotionWaitTime = wait;
}
public bool IsKeyboardEmotion()
{
if (_KeyboardEmotionWaitTime > 0f)
{
_KeyboardEmotionWaitTime -= Time.deltaTime;
return false;
}
if (Input.GetKeyDown(KeyCode.Alpha1))
{
return true;
}
return false;
}
public bool IsKeyboardBattleLog()
{
if (Input.GetKeyDown(KeyCode.B))
{
return true;
}
return false;
}
public bool IsKeyboardBattleMenu()
{
if (Input.GetKeyDown(KeyCode.Escape))
{
return true;
}
return false;
}
public bool IsKeyboardDeckNextPage()
{
if (Input.GetKeyDown(KeyCode.X) || Input.GetKeyDown(KeyCode.Period))
{
return true;
}
return false;
}
public bool IsKeyboardDeckPrevPage()
{
if (Input.GetKeyDown(KeyCode.Z) || Input.GetKeyDown(KeyCode.Comma))
{
return true;
}
return false;
}
public bool IsKeyboardClassInfomation()
{
if (Input.GetKey(KeyCode.Tab))
{
return true;
}
return false;
}
public bool IsKeyboardAny()
{
if (!IsKeyboardUpArrow() && !IsKeyboardDownArrow() && !IsKeyboardRightArrow() && !IsKeyboardLeftArrow() && !IsKeyboardEnter() && !IsKeyboardSpace() && !IsKeyboardShift() && !IsKeyboardCancel() && !IsKeyboardEvolve() && !IsKeyboardEmotion() && !IsKeyboardBattleLog() && !IsKeyboardBattleMenu())
{
return IsKeyboardClassInfomation();
}
return true;
}
public bool IsAnyMouse()
{
if (!MouseControl || _clickState == ClickState.None)
{
return !IsNone();
}
return true;
}
}