Multi-instancing migration (Step 4): convert Wizard.ToolboxGame.RealTimeNetworkAgent — the per-battle handle to the live PvP/AI network agent (RealTimeNetworkAgent owns the Socket.IO connection, OnEmit pipeline, and ack bookkeeping for one battle) — to resolve through BattleAmbient.Current when a scope is active, falling back to a renamed `_realTimeNetworkAgentFallback` static when not. The original was an auto-property with a private setter, mutated only via SetRealTimeNetworkBattle / DestroyNetworkAgent; converting to a manual property + ambient-aware mutators keeps the public surface byte-identical (design 2026-06-07-engine-multi-instancing, Task 4). DestroyNetworkAgent preserves the original Unity DestroyImmediate(.gameObject) call exactly, just reading the "current" agent through the same ambient-first resolution and clearing the slot it came from. Object.DestroyImmediate resolves via the file's existing `using UnityEngine;` (no qualifier change needed — matches the file's existing pattern at line 36/79 that calls `GameObject.Find` unqualified). In-file references (3 sites) handled as follows: - line 28 auto-property → renamed backing + manual ambient-first getter - line 57 SetRealTimeNetworkBattle → writes through Current?.NetworkAgent or fallback - line 62 DestroyNetworkAgent → reads current via ambient-first; clears the same slot --- Engine/Wizard/ToolboxGame.cs (~line 28) - public static RealTimeNetworkAgent RealTimeNetworkAgent { get; private set; } + private static RealTimeNetworkAgent _realTimeNetworkAgentFallback; + public static RealTimeNetworkAgent RealTimeNetworkAgent + { + get => SVSim.BattleEngine.Ambient.BattleAmbient.Current?.NetworkAgent ?? _realTimeNetworkAgentFallback; + } --- Engine/Wizard/ToolboxGame.cs (~lines 57-69) public static void SetRealTimeNetworkBattle(RealTimeNetworkAgent agent) { - RealTimeNetworkAgent = agent; + var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current; + if (c != null) c.NetworkAgent = agent; + else _realTimeNetworkAgentFallback = agent; } public static void DestroyNetworkAgent() { - if (RealTimeNetworkAgent != null) + var c = SVSim.BattleEngine.Ambient.BattleAmbient.Current; + var current = c?.NetworkAgent ?? _realTimeNetworkAgentFallback; + if (current != null) { - Object.DestroyImmediate(RealTimeNetworkAgent.gameObject); - RealTimeNetworkAgent = null; + Object.DestroyImmediate(current.gameObject); + if (c != null) c.NetworkAgent = null; + else _realTimeNetworkAgentFallback = null; } }