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 PostDrawLayer(Layer layer) { if (NetworkDebugger._instances.Count == 0) { return; } if (layer == Layer.Console) { if (NetworkDebugger._interfaces[0].pin || (double)Mouse.xConsole < (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0) { DevConsoleCore core = DevConsole.core; DevConsole.core = NetworkDebugger._instances[0].consoleCore; NetworkDebugger._interfaces[0].Draw(NetworkDebugger._instances[0].network); DevConsole.core = core; } else { NetworkDebugger._interfaces[0].visible = false; } if (NetworkDebugger._interfaces[1].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole < (double)Layer.Console.height / 2.0) { if (NetworkDebugger._instances.Count > 1) { DevConsoleCore core = DevConsole.core; DevConsole.core = NetworkDebugger._instances[1].consoleCore; NetworkDebugger._interfaces[1].Draw(NetworkDebugger._instances[1].network); DevConsole.core = core; } } else { NetworkDebugger._interfaces[1].visible = false; } if (NetworkDebugger._interfaces[2].pin || (double)Mouse.xConsole <(double)Layer.Console.width / 2.0 && (double)Mouse.yConsole> (double) Layer.Console.height / 2.0) { if (NetworkDebugger._instances.Count > 2) { DevConsoleCore core = DevConsole.core; DevConsole.core = NetworkDebugger._instances[2].consoleCore; NetworkDebugger._interfaces[2].Draw(NetworkDebugger._instances[2].network); DevConsole.core = core; } } else { NetworkDebugger._interfaces[2].visible = false; } if (NetworkDebugger._interfaces[3].pin || (double)Mouse.xConsole > (double)Layer.Console.width / 2.0 && (double)Mouse.yConsole > (double)Layer.Console.height / 2.0) { if (NetworkDebugger._instances.Count > 3) { DevConsoleCore core = DevConsole.core; DevConsole.core = NetworkDebugger._instances[3].consoleCore; NetworkDebugger._interfaces[3].Draw(NetworkDebugger._instances[3].network); DevConsole.core = core; } } else { NetworkDebugger._interfaces[3].visible = false; } if (this._connectionArrow == null) { this._connectionArrow = new SpriteMap("connectionArrow", 56, 13); this._connectionArrow.CenterOrigin(); this._connectionX = new Sprite("connectionX"); this._connectionX.CenterOrigin(); } for (int i = 0; i < 4; ++i) { if (NetworkDebugger._instances.Count > i && NetworkDebugger._instances[i].active) { for (int j = 0; j < 4; ++j) { if (i != j && NetworkDebugger._instances.Count > j && NetworkDebugger._instances[j].active) { NetworkConnection networkConnection1 = NetworkDebugger._instances[i].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(j))); NetworkConnection networkConnection2 = NetworkDebugger._instances[j].network.core.connections.FirstOrDefault <NetworkConnection>((Func <NetworkConnection, bool>)(x => x.identifier == NetworkDebugger.GetID(i))); Vec2 vec2_1 = NetworkDebugger._interfaces[i].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10)); Vec2 vec2_2 = NetworkDebugger._interfaces[j].position + new Vec2((float)(DuckGame.Graphics.width / 4 - 10), (float)(DuckGame.Graphics.height / 4 - 10)); Vec2 p2 = vec2_2 - vec2_1; Vec2 vec2_3 = p2.normalized.Rotate(Maths.DegToRad(90f), Vec2.Zero); float num1 = -Maths.PointDirection(Vec2.Zero, p2); float num2 = 0.0f; if (networkConnection1 != null) { float num3 = 0.0f; float num4 = 0.0f; if (networkConnection2 != null) { num3 = NetworkDebugger.GetReceived(networkConnection1.identifier, networkConnection2.identifier); num4 = NetworkDebugger.GetSent(networkConnection1.identifier, networkConnection2.identifier); num2 = 6f; } this._connectionArrow.frame = networkConnection1.status != ConnectionStatus.Connected ? 0 : 3; this._connectionArrow.angleDegrees = num1; this._connectionArrow.alpha = 1f; this._connectionArrow.depth = new Depth(0.92f); Vec2 vec2_4 = (vec2_1 + vec2_2) / 2f + vec2_3 * num2; DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y); if (networkConnection1.status != ConnectionStatus.Disconnecting) { this._connectionX.depth = new Depth(0.98f); Vec2 vec2_5 = vec2_4 - p2.normalized * 22f; if ((double)(Mouse.positionConsole - vec2_5).length < 8.0) { this._connectionX.alpha = 1f; if (this.lefpres) { networkConnection1.Disconnect(); SFX.Play("quack"); } } else { this._connectionX.alpha = 0.4f; } DuckGame.Graphics.Draw(this._connectionX, vec2_5.x, vec2_5.y); } if ((double)num4 > 0.0) { ++this._connectionArrow.frame; this._connectionArrow.alpha = num4; this._connectionArrow.depth = new Depth(0.95f); DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y); --this._connectionArrow.frame; } if ((double)num3 > 0.0) { this._connectionArrow.frame += 2; this._connectionArrow.alpha = num3; this._connectionArrow.depth = new Depth(0.95f); DuckGame.Graphics.Draw((Sprite)this._connectionArrow, vec2_4.x, vec2_4.y); this._connectionArrow.frame -= 2; } } } } } } } base.PostDrawLayer(layer); }