public static void Join(string id, string ip = "localhost")
 {
     if (DuckNetwork.core.status != DuckNetStatus.Disconnected)
     {
         return;
     }
     DuckNetwork.Reset();
     foreach (Profile universalProfile in Profiles.universalProfileList)
     {
         universalProfile.team = null;
     }
     for (int index = 0; index < 8; ++index)
     {
         Teams.all[index].customData = null;
     }
     foreach (Profile profile in DuckNetwork.profiles)
     {
         profile.slotType = SlotType.Open;
     }
     DuckNetwork.core.error          = null;
     DuckNetwork.core.localDuckIndex = -1;
     TeamSelect2.DefaultSettings();
     Network.JoinServer(id, 1337, ip);
     DuckNetwork.localConnection.AttemptConnection();
     DuckNetwork.core.attemptTimeout = 15f;
     DuckNetwork.core.status         = DuckNetStatus.EstablishingCommunication;
 }
        public static void Host(int maxPlayers, NetworkLobbyType lobbyType)
        {
            if (_core.status != DuckNetStatus.Disconnected)
            {
                return;
            }
            //            DevConsole.Log(DCSection.DuckNet, "|LIME|Hosting new server. ", -1);

            // Rubbish fix for Update calling host with 4 max players. Need better way
            if (maxPlayers == 4 && lobbyType == NetworkLobbyType.FriendsOnly)
            {
                maxPlayers = 8;
            }

            DuckNetwork.Reset();
            foreach (Profile universalProfile in Profiles.universalProfileList)
            {
                universalProfile.team = (Team)null;
            }
            _core.error = (DuckNetErrorInfo)null;
            TeamSelect2.DefaultSettings();
            Network.HostServer(lobbyType, maxPlayers, "duckGameServer", 1337);
            DuckNetwork.localConnection.AttemptConnection();
            foreach (Profile profile in DuckNetwork.profiles)
            {
                profile.slotType = lobbyType != NetworkLobbyType.Private ? (lobbyType != NetworkLobbyType.FriendsOnly ? SlotType.Open : SlotType.Friend) : SlotType.Invite;
                if ((int)profile.networkIndex >= maxPlayers)
                {
                    profile.slotType = SlotType.Closed;
                }
            }
            int num = 1;

            _core.localDuckIndex = -1;
            foreach (MatchmakingPlayer matchmakingProfile in UIMatchmakingBox.matchmakingProfiles)
            {
                string name = Network.activeNetwork.core.GetLocalName();
                if (num > 1)
                {
                    name = name + "(" + num.ToString() + ")";
                }
                if (_core.localDuckIndex == -1)
                {
                    _core.localDuckIndex = (int)matchmakingProfile.duckIndex;
                    _core.hostDuckIndex  = (int)matchmakingProfile.duckIndex;
                }
                Profile profile = (Profile)createProfile.Invoke(null, new object[] { _core.localConnection, name, (int)matchmakingProfile.duckIndex, matchmakingProfile.inputProfile, false, false, false });
                if (num > 1)
                {
                    profile.slotType = SlotType.Local;
                }
                profile.networkStatus = DuckNetStatus.Connected;
                if (matchmakingProfile.team != null)
                {
                    if (matchmakingProfile.team.customData != null)
                    {
                        profile.team = Teams.all[(int)matchmakingProfile.duckIndex];
                        Team.MapFacade(profile.steamID, matchmakingProfile.team);
                    }
                    else
                    {
                        profile.team = matchmakingProfile.team;
                    }
                }
                ++num;
            }
            _core.localConnection.isHost = true;
            _core.status = DuckNetStatus.Connecting;
        }