refactor(engine-ambient): ViewerId/RealTimeNetworkAgent/BattleRecoveryInfo read ambient first
Step 4 of multi-instancing migration. Three additional per-battle statics front-fronted by BattleAmbient.Current, each with a static fallback for unwrapped callers. ViewerId's SavedataManager-persisting setter is preserved on the fallback path; inside a scope, the setter is a no-op (the per-battle perspective is fixed at scope entry). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,7 +16,7 @@ public class Certification : MonoBehaviour
|
||||
|
||||
private static string udid;
|
||||
|
||||
private static int viewer_id;
|
||||
private static int _viewerIdFallback;
|
||||
|
||||
private static int short_udid;
|
||||
|
||||
@@ -42,17 +42,25 @@ public class Certification : MonoBehaviour
|
||||
{
|
||||
get
|
||||
{
|
||||
if (viewer_id == 0)
|
||||
var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current;
|
||||
if (c != null) return c.ViewerId;
|
||||
if (_viewerIdFallback == 0)
|
||||
{
|
||||
viewer_id = Toolbox.SavedataManager.GetInt("VIEWER_ID");
|
||||
_viewerIdFallback = Toolbox.SavedataManager.GetInt("VIEWER_ID");
|
||||
}
|
||||
return viewer_id;
|
||||
return _viewerIdFallback;
|
||||
}
|
||||
set
|
||||
{
|
||||
var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current;
|
||||
if (c != null)
|
||||
{
|
||||
// Inside a scope, ViewerId is fixed at scope entry — swallow the write.
|
||||
return;
|
||||
}
|
||||
Toolbox.SavedataManager.SetInt("VIEWER_ID", value);
|
||||
Toolbox.SavedataManager.Save();
|
||||
viewer_id = value;
|
||||
_viewerIdFallback = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +152,7 @@ public class Certification : MonoBehaviour
|
||||
{
|
||||
sessionId = null;
|
||||
udid = null;
|
||||
viewer_id = 0;
|
||||
_viewerIdFallback = 0;
|
||||
short_udid = 0;
|
||||
Toolbox.SavedataManager.SetInt("VIEWER_ID", 0);
|
||||
Toolbox.SavedataManager.SetInt("SHORT_UDID", 0);
|
||||
|
||||
Reference in New Issue
Block a user