Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
        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;
        }