refactor(engine-ambient): BattleManagerBase.GetIns reads ambient first, static fallback
Step 3 of multi-instancing migration. The dominant per-battle singleton now resolves through BattleAmbient.Current.Mgr when a scope is active. The legacy 'main' field is renamed _mainFallback and retained for unwrapped callers (tests, anything not yet scope-wrapped). GetIns() still returns null when neither is set, preserving the '?.Foo ?? default' patterns in engine code. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -410,7 +410,7 @@ public class BattleManagerBase
|
||||
|
||||
private NetworkTouchControl _networkTouchControl;
|
||||
|
||||
private static BattleManagerBase main;
|
||||
private static BattleManagerBase _mainFallback;
|
||||
|
||||
private static bool _isRandomDrawFallback = false;
|
||||
public static bool IsRandomDraw {
|
||||
@@ -724,12 +724,12 @@ public class BattleManagerBase
|
||||
|
||||
public static BattleManagerBase GetIns()
|
||||
{
|
||||
return main;
|
||||
return SVSim.BattleEngine.Ambient.BattleAmbient.Current?.Mgr ?? _mainFallback;
|
||||
}
|
||||
|
||||
protected BattleManagerBase(IBattleMgrContentsCreator contentsCreator)
|
||||
{
|
||||
main = this;
|
||||
_mainFallback = this;
|
||||
BattleLifeTimeSharedObject = new BattleLifeTimeSharedObject();
|
||||
PublishedSkillList = new List<SkillBase>();
|
||||
_contentsCreator = contentsCreator;
|
||||
@@ -1488,7 +1488,7 @@ public class BattleManagerBase
|
||||
GameMgr.GetIns().GetPrefabMgr().DisposeAllClonedObject();
|
||||
GameMgr.GetIns().GetGameObjMgr().DisposeUIGameObj();
|
||||
GameMgr.GetIns().GetPrefabMgr().AllUnLoad();
|
||||
main = null;
|
||||
_mainFallback = null;
|
||||
}
|
||||
|
||||
private void DisposeBattleGameObj_DestroyImmediate(GameObject obj)
|
||||
|
||||
Reference in New Issue
Block a user