public void LockInstance(NetworkInstance instance) { this.oldNetwork = Network.activeNetwork; Network.activeNetwork = instance.network; this.oldDuckNetworkCore = DuckNetwork.core; DuckNetwork.core = instance.duckNetworkCore; this.oldVirtualCore = VirtualTransition.core; VirtualTransition.core = instance.virtualCore; this.oldLevelCore = Level.core; Level.core = instance.levelCore; this.oldProfileCore = Profiles.core; Profiles.core = instance.profileCore; this.oldTeamCore = Teams.core; Teams.core = instance.teamsCore; this.oldLayerCore = Layer.core; Layer.core = instance.layerCore; this.oldInputCore = InputProfile.core; InputProfile.core = instance.inputProfile; this.oDevCore = DevConsole.core; DevConsole.core = instance.consoleCore; this.oldCrowdCore = Crowd.core; Crowd.core = instance.crowdCore; this.oldGameModeCore = GameMode.core; GameMode.core = instance.gameModeCore; this.oldConnectionUICore = ConnectionStatusUI.core; ConnectionStatusUI.core = instance.connectionUICore; this.oldMonoCore = MonoMain.core; MonoMain.core = instance.monoCore; }
public void CreateInstance(int init, bool isHost) { NetworkDebugger._networkDrawingIndex = init; NetworkInstance networkInstance = new NetworkInstance() { network = new Network(NetworkDebugger._networkDrawingIndex) }; if (this._startLevel == null) { networkInstance.teamsCore = new TeamsCore(); networkInstance.teamsCore.Initialize(); } else { networkInstance.teamsCore = Teams.core; List <Team> teamList = new List <Team>((IEnumerable <Team>)Teams.core.extraTeams); Teams.core = new TeamsCore(); Teams.core.Initialize(); Teams.core.extraTeams = teamList; } if (this._startLayer != null) { networkInstance.layerCore = this._startLayer; this._startLayer = (LayerCore)null; } else { networkInstance.layerCore = new LayerCore(); networkInstance.layerCore.InitializeLayers(); } networkInstance.virtualCore = new VirtualTransitionCore(); networkInstance.virtualCore.Initialize(); if (this._startLevel == null) { networkInstance.profileCore = new ProfilesCore(); networkInstance.profileCore.Initialize(); networkInstance.profileCore.DefaultPlayer2.team = (Team)null; } else { networkInstance.profileCore = Profiles.core; Profiles.core = new ProfilesCore(); Profiles.core.Initialize(); } networkInstance.inputProfile = new InputProfileCore(); InputProfileCore core1 = InputProfile.core; InputProfile.core = networkInstance.inputProfile; Input.InitDefaultProfiles(); networkInstance.levelCore = new LevelCore(); LevelCore core2 = Level.core; Level.core = networkInstance.levelCore; networkInstance.crowdCore = new CrowdCore(); CrowdCore core3 = Crowd.core; Crowd.core = networkInstance.crowdCore; TeamsCore core4 = Teams.core; networkInstance.teamsCore.extraTeams = new List <Team>((IEnumerable <Team>)Teams.core.extraTeams); Teams.core = networkInstance.teamsCore; ProfilesCore core5 = Profiles.core; Profiles.core = networkInstance.profileCore; LayerCore core6 = Layer.core; Layer.core = networkInstance.layerCore; VirtualTransitionCore core7 = VirtualTransition.core; VirtualTransition.core = networkInstance.virtualCore; Network activeNetwork = Network.activeNetwork; Network.activeNetwork = networkInstance.network; networkInstance.network.DoInitialize(); networkInstance.duckNetworkCore = new DuckNetworkCore(); GameModeCore gameModeCore = new GameModeCore(); networkInstance.gameModeCore = gameModeCore; GameModeCore core8 = GameMode.core; GameMode.core = gameModeCore; networkInstance.connectionUICore = new ConnectionStatusUICore(); ConnectionStatusUICore core9 = ConnectionStatusUI.core; ConnectionStatusUI.core = networkInstance.connectionUICore; networkInstance.consoleCore = new DevConsoleCore(); DevConsoleCore core10 = DevConsole.core; DevConsole.core = networkInstance.consoleCore; DuckNetworkCore core11 = DuckNetwork.core; DuckNetwork.core = networkInstance.duckNetworkCore; DuckNetwork.Initialize(); networkInstance.monoCore = new MonoMainCore(); MonoMainCore core12 = MonoMain.core; MonoMain.core = networkInstance.monoCore; if (isHost) { foreach (Profile profile in Profiles.all) { if (profile.team != null) { NetworkDebugger.inputProfiles[Persona.Number(profile.persona)] = InputProfile.defaultProfiles[Persona.Number(profile.persona)]; } } DuckNetwork.Host(4, NetworkLobbyType.Public); if (this._startLevel != null) { Level.current = this._startLevel; this._startLevel.NetworkDebuggerPrepare(); this._startLevel = (Level)null; } else { Level.current = (Level) new TeamSelect2(); } } else { Level.current = (Level) new JoinServer(0UL); } networkInstance.joined = true; if (init >= NetworkDebugger._instances.Count) { NetworkDebugger._instances.Add(networkInstance); } else { NetworkDebugger._instances[init] = networkInstance; } base.Initialize(); InputProfile.core = core1; Network.activeNetwork = activeNetwork; DuckNetwork.core = core11; Teams.core = core4; Profiles.core = core5; Layer.core = core6; VirtualTransition.core = core7; Level.core = core2; DevConsole.core = core10; Crowd.core = core3; GameMode.core = core8; ConnectionStatusUI.core = core9; MonoMain.core = core12; }
public override void DoUpdate() { this.lefpres = Mouse.left == InputState.Pressed; List <DCLine> dcLineList = (List <DCLine>)null; lock (DevConsole.debuggerLines) { dcLineList = DevConsole.debuggerLines; DevConsole.debuggerLines = new List <DCLine>(); } for (int index1 = 0; index1 < 4; ++index1) { if (index1 >= NetworkDebugger._instances.Count || !NetworkDebugger._instances[index1].active) { if (index1 <= NetworkDebugger._instances.Count) { int init = -1; InputProfile inputProfile1 = (InputProfile)null; foreach (InputProfile defaultProfile in InputProfile.defaultProfiles) { if (defaultProfile.Pressed("START")) { foreach (InputProfile inputProfile2 in NetworkDebugger.inputProfiles) { if (defaultProfile == inputProfile2) { break; } } for (int index2 = 0; index2 < 4; ++index2) { if (NetworkDebugger.inputProfiles[index2].name == "") { bool flag = false; foreach (NetDebugInterface netDebugInterface in NetworkDebugger._interfaces) { if (netDebugInterface.visible) { flag = true; break; } } if (!flag) { init = index1; inputProfile1 = defaultProfile; } NetworkDebugger.inputProfiles[index2] = defaultProfile; break; } } } } if (init != -1) { this.CreateInstance(init, false); NetworkDebugger._instances[index1].ipro = inputProfile1; } } } else { NetworkInstance instance = NetworkDebugger._instances[index1]; NetworkDebugger._networkDrawingIndex = index1; this.LockInstance(instance); float volume = SFX.volume; if (NetworkDebugger.Mute(NetworkDebugger._networkDrawingIndex)) { SFX.volume = 0.0f; } InputProfile.Update(); foreach (DCLine dcLine in dcLineList) { if (dcLine.threadIndex == index1) { DevConsole.core.lines.Enqueue(dcLine); } } DevConsole.Update(); Network.PreUpdate(); FireManager.Update(); Level.UpdateLevelChange(); Level.UpdateCurrentLevel(); MonoMain.UpdatePauseMenu(); int index2 = 0; foreach (NetDebugInterface netDebugInterface in NetworkDebugger._interfaces) { MonoMain.instance.IsMouseVisible = true; if (index2 == index1 && index2 < NetworkDebugger._instances.Count) { netDebugInterface.Update(NetworkDebugger._instances[index2].network); } ++index2; } Network.PostUpdate(); if (DuckNetwork.status == DuckNetStatus.Disconnected) { NetworkDebugger._instances[index1].active = false; foreach (Profile profile in NetworkDebugger._instances[index1].duckNetworkCore.profiles) { for (int index3 = 0; index3 < 4; ++index3) { if (NetworkDebugger.inputProfiles[index3] == profile.inputProfile || NetworkDebugger.inputProfiles[index3] == NetworkDebugger._instances[index1].ipro) { NetworkDebugger.inputProfiles[index3] = new InputProfile(); } } } } SFX.volume = volume; this.UnlockInstance(); } } if (!Keyboard.Pressed(Keys.F11)) { return; } foreach (NetworkInstance instance in NetworkDebugger._instances) { instance.network.core.ForcefulTermination(); } Network.activeNetwork.core.ForcefulTermination(); NetworkDebugger._instances.Clear(); NetworkDebugger.inputProfiles.Clear(); Level.current = (Level) new NetworkDebugger(); }