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:
gamer147
2026-06-07 21:37:58 -04:00
parent 4e756a6c46
commit fe146fde50
9 changed files with 230 additions and 16 deletions

View File

@@ -151,7 +151,7 @@ internal static class EngineGlobalInit
// targetList[0]. Seed the backing field with a stable nonzero id so the getter short-circuits.
// It defines the engine's "player" perspective: a target vid == ThisViewerId resolves on
// BattlePlayer (engine seat A), vid != it on BattleEnemy (seat B). Only set when 0 (coexistence).
var viewerIdField = typeof(Certification).GetField("viewer_id",
var viewerIdField = typeof(Certification).GetField("_viewerIdFallback",
BindingFlags.Static | BindingFlags.NonPublic)!;
if ((int)(viewerIdField.GetValue(null) ?? 0) == 0)
viewerIdField.SetValue(null, ThisViewerId);