Пример #1
0
 public override void Update()
 {
     if (DuckNetwork.status == DuckNetStatus.Disconnected && !this._attemptedConnection)
     {
         this._startedJoining = true;
         if (Profiles.active.Count == 0)
         {
             Profiles.DefaultPlayer1.team = Teams.Player1;
         }
         TeamSelect2.FillMatchmakingProfiles();
         if (this._lobbyID == 0UL)
         {
             DuckNetwork.Join("duckGameServer");
         }
         else
         {
             DuckNetwork.Join(this._lobbyID.ToString());
         }
         this._attemptedConnection = true;
     }
     else if (DuckNetwork.status == DuckNetStatus.Disconnected && this._attemptedConnection)
     {
         Level.current = (Level) new ConnectionError("|RED|CONNECTION FAILED!");
     }
     base.Update();
 }
Пример #2
0
 public static void Update()
 {
     if (!Steam.IsInitialized() || !Network.isServer || TeamSelect2.GetSettingInt("workshopmaps") <= 0)
     {
         return;
     }
     if (RandomLevelDownloader._downloading != null)
     {
         if (!RandomLevelDownloader._downloading.finishedProcessing)
         {
             return;
         }
         if (RandomLevelDownloader._downloading.downloadResult == SteamResult.OK)
         {
             RandomLevelDownloader.SearchDirLevels(RandomLevelDownloader._downloading.path, LevelLocation.Workshop);
         }
         RandomLevelDownloader._downloading = (WorkshopItem)null;
     }
     else
     {
         if (RandomLevelDownloader._currentQuery != null || RandomLevelDownloader._readyLevels.Count == RandomLevelDownloader.numToHaveReady)
         {
             return;
         }
         RandomLevelDownloader._toFetchIndex = -1;
         RandomLevelDownloader._numFetch     = 0;
         RandomLevelDownloader._currentQuery = Steam.CreateQueryAll(RandomLevelDownloader._orderMode, WorkshopType.Items);
         RandomLevelDownloader._currentQuery.requiredTags.Add("Deathmatch");
         RandomLevelDownloader._currentQuery.QueryFinished += new WorkshopQueryFinished(RandomLevelDownloader.FinishedTotalQuery);
         RandomLevelDownloader._currentQuery.fetchedData    = WorkshopQueryData.TotalOnly;
         RandomLevelDownloader._currentQuery.Request();
         DevConsole.Log(DCSection.Steam, "Querying for random levels.");
     }
 }
Пример #3
0
 public override bool Hit(Bullet bullet, Vec2 hitPos)
 {
     if ((double)this._hitPoints <= 0.0)
     {
         return(false);
     }
     if (bullet.isLocal && this.owner == null)
     {
         Thing.Fondle((Thing)this, DuckNetwork.localConnection);
     }
     for (int index = 0; (double)index < 1.0 + (double)this.damageMultiplier / 2.0; ++index)
     {
         Level.Add((Thing) new GlassParticle(hitPos.x, hitPos.y, bullet.travelDirNormalized));
     }
     SFX.Play("woodHit");
     if (bullet.isLocal)
     {
         this._hitPoints       -= this.damageMultiplier;
         this.damageMultiplier += 2f;
         if (TeamSelect2.Enabled("EXPLODEYCRATES"))
         {
             if (this.duck != null)
             {
                 this.duck.ThrowItem();
             }
             this.Destroy((DestroyType) new DTShot(bullet));
             Level.Add((Thing) new GrenadeExplosion(this.x, this.y));
         }
         if ((double)this._hitPoints <= 0.0)
         {
             this.Destroy((DestroyType) new DTShot(bullet));
         }
     }
     return(base.Hit(bullet, hitPos));
 }
 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;
 }
Пример #5
0
 public override bool Hit(Bullet bullet, Vec2 hitPos)
 {
     if (bullet.isLocal && TeamSelect2.Enabled("EXPLODEYCRATES"))
     {
         if (this.duck != null)
         {
             this.duck.ThrowItem();
         }
         this.Destroy((DestroyType) new DTShot(bullet));
         Level.Remove((Thing)this);
         Level.Add((Thing) new GrenadeExplosion(this.x, this.y));
     }
     return(base.Hit(bullet, hitPos));
 }
        public static void DoInvite()
        {
            bool _attemptingToInvite = (bool)typeof(TeamSelect2).GetField("_attemptingToInvite", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).GetValue(Level.current as TeamSelect2);

            if (!Network.isActive)
            {
                bool _didHost = (bool)typeof(TeamSelect2).GetField("_didHost", BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public).GetValue(Level.current as TeamSelect2);

                TeamSelect2.FillMatchmakingProfiles();
                DuckNetwork.Host(8, NetworkLobbyType.FriendsOnly);
                (Level.current as TeamSelect2).PrepareForOnline();
                _didHost = true;
            }
            _attemptingToInvite = true;
        }
Пример #7
0
 public override bool Hit(Bullet bullet, Vec2 hitPos)
 {
     if ((double)this._hitPoints <= 0.0)
     {
         return(base.Hit(bullet, hitPos));
     }
     if (bullet.isLocal && this.owner == null)
     {
         Thing.Fondle((Thing)this, DuckNetwork.localConnection);
     }
     for (int index = 0; (double)index < 1.0 + (double)this.damageMultiplier / 2.0; ++index)
     {
         Thing thing = (Thing)WoodDebris.New(hitPos.x, hitPos.y);
         thing.hSpeed = (float)(-(double)bullet.travelDirNormalized.x * 2.0 * ((double)Rando.Float(1f) + 0.300000011920929));
         thing.vSpeed = (float)(-(double)bullet.travelDirNormalized.y * 2.0 * ((double)Rando.Float(1f) + 0.300000011920929)) - Rando.Float(2f);
         Level.Add(thing);
     }
     SFX.Play("woodHit");
     if (bullet.isLocal && TeamSelect2.Enabled("EXPLODEYCRATES"))
     {
         Thing.Fondle((Thing)this, DuckNetwork.localConnection);
         if (this.duck != null)
         {
             this.duck.ThrowItem();
         }
         this.Destroy((DestroyType) new DTShot(bullet));
         Level.Add((Thing) new GrenadeExplosion(this.x, this.y));
     }
     if (bullet.isLocal)
     {
         this._hitPoints       -= this.damageMultiplier;
         this.damageMultiplier += 2f;
     }
     if ((double)this._hitPoints <= 0.0)
     {
         this.Destroy((DestroyType) new DTShot(bullet));
     }
     return(base.Hit(bullet, hitPos));
 }
 public override void Activate()
 {
     TeamSelect2.GetMatchSetting("requiredwins").value = (object)(int)this.winsPerSet;
     TeamSelect2.GetMatchSetting("restsevery").value   = (object)(int)this.roundsPerIntermission;
     TeamSelect2.GetMatchSetting("randommaps").value   = (object)(int)this.randomPercent;
     TeamSelect2.GetMatchSetting("workshopmaps").value = (object)(int)this.workshopPercent;
     TeamSelect2.GetMatchSetting("normalmaps").value   = (object)(int)this.normalPercent;
     TeamSelect2.GetMatchSetting("custommaps").value   = (object)(int)this.customPercent;
     TeamSelect2.GetMatchSetting("wallmode").value     = (object)this.wallmode;
     RockScoreboard.wallMode = this.wallmode;
     TeamSelect2.GetOnlineSetting("teams").value = (object)this.teams;
     TeamSelect2.prevCustomLevels = TeamSelect2.customLevels;
     TeamSelect2.customLevels     = this.customLevels;
     foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Modifier))
     {
         unlock.enabled = this._enabledModifiers.Contains(Unlocks.modifierToByte[unlock.id]);
         if (this.initialSettings)
         {
             unlock.prevEnabled = unlock.enabled;
         }
     }
     GameMode.roundsBetweenIntermission = (int)this.roundsPerIntermission;
     GameMode.winsPerSet = (int)this.winsPerSet;
     TeamSelect2.UpdateModifierStatus();
     if (this.initialSettings)
     {
         foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
         {
             matchSetting.prevValue = matchSetting.value;
         }
         foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings)
         {
             onlineSetting.prevValue = onlineSetting.value;
         }
     }
     base.Activate();
 }
 public override void Update()
 {
     if (this.open)
     {
         if (Input.Pressed("UP") && this._selection > 0)
         {
             --this._selection;
             SFX.Play("textLetter", 0.7f);
         }
         if (Input.Pressed("DOWN") && this._selection < this._users.Count - 1)
         {
             ++this._selection;
             SFX.Play("textLetter", 0.7f);
         }
         if (this._selection >= this._viewTop + this._maxShow)
         {
             this._viewTop = this._selection - (this._maxShow - 1);
         }
         if (this._selection < this._viewTop)
         {
             this._viewTop = this._selection;
         }
         if (Input.Pressed("QUACK"))
         {
             this._menuAction.Activate();
             SFX.Play("resume", 0.6f);
         }
         if (this._users.Count > 0 && Input.Pressed("SHOOT") && !this._users[this._selection].triedInvite)
         {
             SFX.Play("rockHitGround", 0.8f);
             this._users[this._selection].triedInvite = true;
             TeamSelect2.InvitedFriend(this._users[this._selection].user);
         }
     }
     base.Update();
 }
Пример #10
0
        public void ReplaceHat(TeamHat teamHat, TeamHat newHat)
        {
            if (teamHat == null ||
                teamSpawnsDone.ContainsKey(teamHat) ||
                Level.current == null
                )
            {
                //|| !(Level.current is GameLevel
                //|| Level.current is Editor
                // || Level.current is TeamSelect2))
                //throw new Exception("DUCKZ!" + Level.current.ToString());
                return;
            }

            //throw new Exception("Attempted to replace a hat! " + teamHat.team.hat.texture.textureName);

            if (teamHat.isServerForObject)
            {
                Level.Add(newHat);
                Duck d = teamHat.equippedDuck;
                if (d != null)
                {
                    d.Equip(newHat, false);
                    d.Fondle(newHat);

                    TeamSelect2 lobby = Level.current as TeamSelect2;
                    if (lobby != null)
                    {
                        ProfileBox2 box = lobby.GetBox(d.PlayerIndex());
                        box._hatSelector.hat = newHat;
                    }
                }
            }
            Level.Remove(teamHat);
            teamSpawnsDone.Add(teamHat, null);
        }
        public override void Update()
        {
            this._scroll += 0.1f;
            if ((double)this._scroll > 9.0)
            {
                this._scroll = 0.0f;
            }
            this._dots += 0.01f;
            if ((double)this._dots > 1.0)
            {
                this._dots = 0.0f;
            }
            if (this.open)
            {
                foreach (BlacklistServer failedAttempt in this._failedAttempts)
                {
                    failedAttempt.cooldown = Lerp.Float(failedAttempt.cooldown, 0.0f, Maths.IncFrameTimer());
                }
                if (this._signalCrossLocal.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseLocal)
                    {
                        this._signalCrossLocal.SetAnimation("flicker");
                        UIMatchmakingBox.pulseLocal = false;
                    }
                }
                else if (this._signalCrossLocal.finished)
                {
                    this._signalCrossLocal.SetAnimation("idle");
                }
                if (this._signalCrossNetwork.currentAnimation == "idle")
                {
                    if (UIMatchmakingBox.pulseNetwork)
                    {
                        this._signalCrossNetwork.SetAnimation("flicker");
                        UIMatchmakingBox.pulseNetwork = false;
                    }
                }
                else if (this._signalCrossNetwork.finished)
                {
                    this._signalCrossNetwork.SetAnimation("idle");
                }
                if (Network.connections.Count > 0 && UIMatchmakingBox._state != MatchmakingState.Connecting)
                {
                    this.ChangeState(MatchmakingState.Connecting);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Network appears to be connecting...", Color.White);
                }
                if (DuckNetwork.status == DuckNetStatus.Connected)
                {
                    if (this._tryHostingLobby != null)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new TeamSelect2();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (HOST).", Color.White);
                        return;
                    }
                    if (Level.current is TeamSelect2)
                    {
                        (Level.current as TeamSelect2).CloseAllDialogs();
                        Level.current = (Level) new ConnectingScreen();
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Finished! (CLIENT).", Color.White);
                        return;
                    }
                    Network.Disconnect();
                    this.ChangeState(MatchmakingState.SearchForLobbies);
                    DevConsole.Log("|PURPLE|MATCHMAKING |DGGREEN|Last minute connection error.", Color.White);
                    return;
                }
                switch (UIMatchmakingBox._state)
                {
                case MatchmakingState.ConnectToMoon:
                    Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                    Steam.SearchForLobby((User)null);
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.ConnectingToMoon);
                    break;

                case MatchmakingState.ConnectingToMoon:
                    if (Steam.lobbySearchComplete)
                    {
                        if (this.searchTryIndex == 0)
                        {
                            this._totalInGameLobbies = Steam.lobbiesFound;
                            if (this._totalInGameLobbies < 0)
                            {
                                this._totalInGameLobbies = 0;
                            }
                            ++this.searchTryIndex;
                            Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                            Steam.SearchForLobby((User)null);
                            break;
                        }
                        UIMatchmakingBox.pulseNetwork = true;
                        this._totalLobbiesFound       = Steam.lobbiesFound;
                        List <User> users = Steam.GetSearchLobbyAtIndex(0).users;
                        this._newStatusList.Add("|DGGREEN|Connected to Moon!");
                        this._newStatusList.Add("");
                        this._newStatusList.Add("|DGYELLOW|Searching for companions.");
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        break;
                    }
                    break;

                case MatchmakingState.SearchForLobbies:
                    if (this._triesSinceSearch == 3)
                    {
                        Steam.AddLobbyStringFilter("started", "true", SteamLobbyComparison.Equal);
                        Steam.SearchForLobby((User)null);
                        this.ChangeState(MatchmakingState.CheckingTotalGames);
                        return;
                    }
                    if (this._tries > 0 && this._tryHostingLobby == null)
                    {
                        DuckNetwork.Host(TeamSelect2.GetSettingInt("maxplayers"), NetworkLobbyType.Public);
                        this._tryHostingLobby = (Network.activeNetwork.core as NCSteam).lobby;
                        if (!this.triedHostingAlready)
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching even harder.");
                        }
                        else
                        {
                            this._newStatusList.Add("|DGYELLOW|Searching.");
                        }
                        this.triedHostingAlready = true;
                        DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Opened lobby while searching.", Color.White);
                        this._tryHostingWait = 5f + Rando.Float(2f);
                    }
                    foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
                    {
                        if (matchSetting.value is int)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (int)matchSetting.value, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (int)matchSetting.defaultValue);
                            }
                        }
                        if (matchSetting.value is bool)
                        {
                            if (matchSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(matchSetting.id, (bool)matchSetting.value ? 1 : 0, (SteamLobbyComparison)matchSetting.filterMode);
                            }
                            else if (!matchSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(matchSetting.id, (bool)matchSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings)
                    {
                        if (onlineSetting.value is int)
                        {
                            if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (int)onlineSetting.value, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (int)onlineSetting.defaultValue);
                            }
                        }
                        if (onlineSetting.value is bool)
                        {
                            if (onlineSetting.id == "modifiers")
                            {
                                if (onlineSetting.filtered)
                                {
                                    Steam.AddLobbyStringFilter(onlineSetting.id, (bool)onlineSetting.value ? "true" : "false", SteamLobbyComparison.Equal);
                                }
                            }
                            else if (onlineSetting.filtered)
                            {
                                Steam.AddLobbyNumericalFilter(onlineSetting.id, (bool)onlineSetting.value ? 1 : 0, (SteamLobbyComparison)onlineSetting.filterMode);
                            }
                            else if (!onlineSetting.filtered)
                            {
                                Steam.AddLobbyNearFilter(onlineSetting.id, (bool)onlineSetting.defaultValue ? 1 : 0);
                            }
                        }
                    }
                    Steam.AddLobbyStringFilter("started", "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("beta", "2.0", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("dev", DG.devBuild ? "true" : "false", SteamLobbyComparison.Equal);
                    Steam.AddLobbyStringFilter("modhash", ModLoader.modHash, SteamLobbyComparison.Equal);
                    if (!Steam.waitingForGlobalStats)
                    {
                        this._globalKills = (long)Steam.GetDailyGlobalStat("kills");
                    }
                    Steam.RequestGlobalStats();
                    UIMatchmakingBox.pulseLocal = true;
                    this.ChangeState(MatchmakingState.Searching);
                    ++this._triesSinceSearch;
                    ++this._tries;
                    break;

                case MatchmakingState.CheckingTotalGames:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalInGameLobbies = Steam.lobbiesFound;
                        if (this._totalInGameLobbies < 0)
                        {
                            this._totalInGameLobbies = 0;
                        }
                        this.ChangeState(MatchmakingState.SearchForLobbies);
                        this._triesSinceSearch = 0;
                        break;
                    }
                    break;

                case MatchmakingState.Searching:
                    if (Steam.lobbySearchComplete)
                    {
                        this._totalLobbiesFound = Steam.lobbiesFound;
                        if (this._tryHostingLobby != null)
                        {
                            --this._totalLobbiesFound;
                        }
                        List <Lobby> lobbyList = new List <Lobby>();
                        DevConsole.Log("|PURPLE|MATCHMAKING |LIME|found " + (object)Math.Max(this._totalLobbiesFound, 0) + " lobbies.", Color.White);
                        for (int index1 = 0; index1 < 2; ++index1)
                        {
                            int num1 = index1 != 0 ? lobbyList.Count : Steam.lobbiesFound;
                            for (int index2 = 0; index2 < num1; ++index2)
                            {
                                Lobby lobby = index1 != 0 ? lobbyList[index2] : Steam.GetSearchLobbyAtIndex(index2);
                                if (this._tryHostingLobby == null || (long)lobby.id != (long)this._tryHostingLobby.id)
                                {
                                    if (index2 == Steam.lobbiesFound - 1)
                                    {
                                        this._failedAttempts.RemoveAll((Predicate <BlacklistServer>)(x => (double)x.cooldown <= 0.0));
                                    }
                                    if (UIMatchmakingBox.nonPreferredServers.Contains(lobby.id) && index1 == 0)
                                    {
                                        lobbyList.Add(lobby);
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (NOT PREFERRED)", Color.White);
                                    }
                                    else if (this.IsBlacklisted(lobby.id))
                                    {
                                        DevConsole.Log("|PURPLE|MATCHMAKING |DGRED|Skipping " + (object)lobby.id + " (BLACKLISTED)", Color.White);
                                    }
                                    else
                                    {
                                        if (this._tryHostingLobby != null)
                                        {
                                            int num2 = -1;
                                            try
                                            {
                                                string lobbyData = lobby.GetLobbyData("randomID");
                                                if (lobbyData != "")
                                                {
                                                    num2 = Convert.ToInt32(lobbyData);
                                                }
                                            }
                                            catch
                                            {
                                            }
                                            if (num2 == -1)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Bad lobby seed.", Color.White);
                                                num2 = Rando.Int(2147483646);
                                            }
                                            if (num2 >= this._tryHostingLobby.randomID)
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Lobby beats own lobby, Attempting join.", Color.White);
                                            }
                                            else
                                            {
                                                DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Skipping lobby (Chose to keep hosting).", Color.White);
                                                NCSteam.UpdateRandomID(this._tryHostingLobby);
                                                continue;
                                            }
                                        }
                                        this._tryConnectLobby = lobby;
                                        if (lobby.owner != null)
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join " + lobby.owner.name + ".");
                                        }
                                        else
                                        {
                                            this._newStatusList.Add("|LIME|Trying to join server.");
                                        }
                                        this.ChangeState(MatchmakingState.Disconnect);
                                        break;
                                    }
                                }
                            }
                        }
                        if (this._tryConnectLobby == null)
                        {
                            DevConsole.Log("|PURPLE|MATCHMAKING |DGYELLOW|Found no valid lobbies.", Color.White);
                            this.ChangeState(MatchmakingState.SearchForLobbies, 3f);
                            break;
                        }
                        break;
                    }
                    break;

                case MatchmakingState.Waiting:
                    this._stateWait -= Maths.IncFrameTimer();
                    if ((double)this._stateWait <= 0.0)
                    {
                        this._stateWait = 0.0f;
                        this.OnStateChange(this._pendingState);
                        break;
                    }
                    break;

                default:
                    int state = (int)UIMatchmakingBox._state;
                    break;
                }
                if (Input.Pressed("QUACK"))
                {
                    this._quit = true;
                    this.ChangeState(MatchmakingState.Disconnect);
                }
            }
            if (this._newStatusList.Count > 0)
            {
                this._newStatusWait -= 0.1f;
                if ((double)this._newStatusWait <= 0.0)
                {
                    this._newStatusWait = 1f;
                    while ((double)this._fancyFont.GetWidth(this._newStatusList[0]) > 98.0)
                    {
                        this._newStatusList[0] = this._newStatusList[0].Substring(0, this._newStatusList[0].Length - 1);
                    }
                    this._statusList.Add(this._newStatusList[0]);
                    if (this._statusList.Count > 7)
                    {
                        this._statusList.RemoveAt(0);
                    }
                    this._newStatusList.RemoveAt(0);
                }
            }
            base.Update();
        }
Пример #12
0
            static bool Prefix(TeamSelect2 __instance)
            {
                // TO IMPLEMENT
                //++Global.data.bootedSinceUpdate;
                //Global.Save();
                // TO IMPLEMENT

                List <DuckPersona> personas = Persona.all as List <DuckPersona>;
                // Get the private fields by reflection
                Type teamselect2type = typeof(TeamSelect2);

                dynamic littleFont           = teamselect2type.GetField("_littleFont", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic countdownScreen      = teamselect2type.GetField("_countdownScreen", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic countdown            = teamselect2type.GetField("_countdown", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic profiles             = teamselect2type.GetField("_profiles", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic font                 = teamselect2type.GetField("_font", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic buttons              = teamselect2type.GetField("_buttons", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic beam                 = teamselect2type.GetField("_beam", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic configGroup          = teamselect2type.GetField("_configGroup", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic multiplayerMenu      = teamselect2type.GetField("_multiplayerMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic modifierMenu         = teamselect2type.GetField("_modifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic levelSelectMenu      = teamselect2type.GetField("_levelSelectMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic playOnlineGroup      = teamselect2type.GetField("_playOnlineGroup", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic playOnlineMenu       = teamselect2type.GetField("_playOnlineMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic hostGameMenu         = teamselect2type.GetField("_hostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic browseGamesMenu      = teamselect2type.GetField("_browseGamesMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic miniHostGameMenu     = teamselect2type.GetField("_miniHostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic joinGameMenu         = teamselect2type.GetField("_joinGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic filtersMenu          = teamselect2type.GetField("_filtersMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic filterModifierMenu   = teamselect2type.GetField("_filterModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic matchmaker           = teamselect2type.GetField("_matchmaker", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic hostGameSettingsMenu = teamselect2type.GetField("_hostGameSettingsMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic hostGameModifierMenu = teamselect2type.GetField("_hostGameModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic createGame           = teamselect2type.GetField("_createGame", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);
                dynamic hostGame             = teamselect2type.GetField("_hostGame", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(__instance);

                // End of getting fields

                TeamSelect2.customLevels = TeamSelect2.prevCustomLevels = 0;
                if (!Network.isActive)
                {
                    Level.core.gameInProgress = false;
                }
                if (!Level.core.gameInProgress)
                {
                    Main.ResetMatchStuff();
                    Main.ResetGameStuff();
                    DuckNetwork.ClosePauseMenu();
                }
                else
                {
                    ConnectionStatusUI.Hide();
                    if (Network.isServer)
                    {
                        if (Steam.lobby != null)
                        {
                            Steam.lobby.SetLobbyData("started", "false");
                            Steam.lobby.joinable = true;
                        }
                        DuckNetwork.inGame = false;
                        foreach (Profile profile in DuckNetwork.profiles)
                        {
                            if (profile.connection == null && profile.slotType != SlotType.Reserved)
                            {
                                profile.slotType = SlotType.Closed;
                            }
                        }
                    }
                }
                if (Network.isActive && Network.isServer)
                {
                    DuckNetwork.ChangeSlotSettings();
                }
                littleFont                 = new BitmapFont("smallBiosFontUI", 7, 5);
                countdownScreen            = new Sprite("title/wideScreen", 0.0f, 0.0f);
                __instance.backgroundColor = Color.Black;
                DuckNetwork.levelIndex     = (byte)0;
                if (Network.isActive && Network.isServer)
                {
                    GhostManager.context.SetGhostIndex((NetIndex16)32);
                }
                countdown        = new SpriteMap("countdown", 32, 32, false);
                countdown.center = new Vec2(16f, 16f);
                Profile defaultProfile1 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == Persona.Duck1);
                    }
                    return(false);
                })) ?? Profiles.DefaultPlayer1;
                Profile defaultProfile2 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == Persona.Duck2);
                    }
                    return(false);
                })) ?? Profiles.DefaultPlayer2;
                Profile defaultProfile3 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == Persona.Duck3);
                    }
                    return(false);
                })) ?? Profiles.DefaultPlayer3;
                Profile defaultProfile4 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == Persona.Duck4);
                    }
                    return(false);
                })) ?? Profiles.DefaultPlayer4;
                Profile defaultProfile5 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == personas[4]);
                    }
                    return(false);
                })) ?? Profiles.core.all.ElementAt(4);
                Profile defaultProfile6 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == personas[5]);
                    }
                    return(false);
                })) ?? Profiles.core.all.ElementAt(5);
                Profile defaultProfile7 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == personas[6]);
                    }
                    return(false);
                })) ?? Profiles.core.all.ElementAt(6);
                Profile defaultProfile8 = Profiles.all.FirstOrDefault <Profile>((Func <Profile, bool>)(x =>
                {
                    if (x.team != null)
                    {
                        return(x.persona == personas[7]);
                    }
                    return(false);
                })) ?? Profiles.core.all.ElementAt(7);

                float       xpos          = 1f;
                ProfileBox2 profileBox2_1 = new ProfileBox2(xpos, 1f, InputProfile.Get("MPPlayer1"), defaultProfile1, __instance, 0);

                profiles.Add(profileBox2_1);
                Level.Add((Thing)profileBox2_1);
                ProfileBox2 profileBox2_2 = new ProfileBox2(xpos + 119f, 1f, InputProfile.Get("MPPlayer2"), defaultProfile2, __instance, 1);

                profiles.Add(profileBox2_2);
                Level.Add((Thing)profileBox2_2);
                ProfileBox2 profileBox2_3 = new ProfileBox2(xpos + 238f, 1f, InputProfile.Get("MPPlayer3"), defaultProfile3, __instance, 2);

                profiles.Add(profileBox2_3);
                Level.Add((Thing)profileBox2_3);
                ProfileBox2 profileBox2_4 = new ProfileBox2(xpos, 62f, InputProfile.Get("MPPlayer4"), defaultProfile4, __instance, 3);

                profiles.Add(profileBox2_4);
                Level.Add((Thing)profileBox2_4);
                ProfileBox2 profileBox2_5 = new ProfileBox2(xpos + 238f, 62f, InputProfile.Get("MPPlayer5"), defaultProfile5, __instance, 4);

                profiles.Add(profileBox2_5);
                Level.Add((Thing)profileBox2_5);
                ProfileBox2 profileBox2_6 = new ProfileBox2(xpos, 121f, InputProfile.Get("MPPlayer6"), defaultProfile6, __instance, 5);

                profiles.Add(profileBox2_6);
                Level.Add((Thing)profileBox2_6);
                ProfileBox2 profileBox2_7 = new ProfileBox2(xpos + 119f, 121f, InputProfile.Get("MPPlayer7"), defaultProfile7, __instance, 6);

                profiles.Add(profileBox2_7);
                Level.Add((Thing)profileBox2_7);
                ProfileBox2 profileBox2_8 = new ProfileBox2(xpos + 238f, 121f, InputProfile.Get("MPPlayer8"), defaultProfile8, __instance, 7);

                profiles.Add(profileBox2_8);
                Level.Add((Thing)profileBox2_8);

                Saxaphone spicySax = new Saxaphone(160f, 100f);

                spicySax.infinite = true;
                Level.Add(spicySax);

                if (Network.isActive)
                {
                    __instance.PrepareForOnline();
                }
                else
                {
                    __instance.BuildPauseMenu(false);
                }
                font       = new BitmapFont("biosFont", 8, -1);
                font.scale = new Vec2(1f, 1f);
                buttons    = new SpriteMap("buttons", 14, 14, false);
                buttons.CenterOrigin();
                buttons.depth = (Depth)0.9f;
                Music.Play("CharacterSelect", true, 0.0f);
                beam = new TeamBeam(101f, 0.0f);
                Level.Add((Thing)beam);

                beam = new TeamBeam(219f, 0.0f);
                Level.Add((Thing)beam);
                TeamSelect2.UpdateModifierStatus();
                configGroup     = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f);
                multiplayerMenu = new UIMenu("@LWING@MATCH SETTINGS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                modifierMenu    = new UIMenu("MODIFIERS", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 240f, -1f, "@DPAD@ADJUST  @QUACK@BACK", (InputProfile)null, false);
                levelSelectMenu = (UIMenu) new LevelSelectCompanionMenu(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, multiplayerMenu);
                foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Modifier))
                {
                    if (unlock.unlocked)
                    {
                        modifierMenu.Add((UIComponent) new UIMenuItemToggle(unlock.shortName, (UIMenuAction)null, new FieldBinding((object)unlock, "enabled", 0.0f, 1f, 0.1f), new Color(), (FieldBinding)null, (List <string>)null, false, false), true);
                    }
                    else
                    {
                        modifierMenu.Add((UIComponent) new UIMenuItem("@TINYLOCK@LOCKED", (UIMenuAction)null, UIAlign.Center, Color.Red, false), true);
                    }
                }
                modifierMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                modifierMenu.Add((UIComponent) new UIMenuItem("OK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)modifierMenu, (UIComponent)multiplayerMenu), UIAlign.Center, new Color(), true), true);
                modifierMenu.Close();
                foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
                {
                    if (!(matchSetting.id == "workshopmaps") || Network.available)
                    {
                        multiplayerMenu.AddMatchSetting(matchSetting, false, true);
                    }
                }
                multiplayerMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                multiplayerMenu.Add((UIComponent) new UIModifierMenuItem((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)multiplayerMenu, (UIComponent)modifierMenu), UIAlign.Center, new Color(), false), true);
                multiplayerMenu.Add((UIComponent) new UICustomLevelMenu((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)multiplayerMenu, (UIComponent)levelSelectMenu), UIAlign.Center, new Color(), false), true);
                multiplayerMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                multiplayerMenu.Add((UIComponent) new UIMenuItem("OK", (UIMenuAction) new UIMenuActionCloseMenu(configGroup), UIAlign.Center, new Color(), true), true);
                multiplayerMenu.Close();
                configGroup.Add((UIComponent)multiplayerMenu, false);
                configGroup.Add((UIComponent)modifierMenu, false);
                configGroup.Add((UIComponent)levelSelectMenu, false);
                configGroup.Close();
                Level.Add((Thing)configGroup);
                playOnlineGroup      = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f);
                playOnlineMenu       = new UIMenu("@PLANET@PLAY ONLINE@PLANET@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                hostGameMenu         = new UIMenu("@LWING@CREATE GAME@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                browseGamesMenu      = (UIMenu) new UIServerBrowser(playOnlineMenu, "SERVER BROWSER", Layer.HUD.camera.width, Layer.HUD.camera.height, 550f, -1f, "@DPAD@@SELECT@JOIN @SHOOT@REFRESH @QUACK@BACK", (InputProfile)null);
                miniHostGameMenu     = new UIMenu("@LWING@HOST GAME@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                joinGameMenu         = new UIMenu("@LWING@FIND GAME@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                filtersMenu          = new UIMenu("@LWING@FILTERS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@SELECT@SELECT  @GRAB@TYPE", (InputProfile)null, false);
                filterModifierMenu   = new UIMenu("@LWING@FILTER MODIFIERS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 240f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                matchmaker           = new UIMatchmakingBox(joinGameMenu, Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f);
                hostGameSettingsMenu = new UIMenu("@LWING@SETTINGS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                hostGameModifierMenu = new UIMenu("@LWING@MODIFIERS@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 240f, -1f, "@DPAD@ADJUST  @SELECT@SELECT", (InputProfile)null, false);
                if ((string)typeof(ModLoader).GetProperty("modHash", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null, null) != "nomods")
                {
                    playOnlineMenu.Add((UIComponent) new UIMenuItem("FIND GAME", (UIMenuAction) new UIMenuActionCloseMenuCallFunction((UIComponent)playOnlineMenu, new UIMenuActionCloseMenuCallFunction.Function(__instance.OpenNoModsFindGame)), UIAlign.Center, new Color(), false), true);
                    playOnlineMenu.Add((UIComponent) new UIMenuItem("CREATE GAME", (UIMenuAction) new UIMenuActionCloseMenuCallFunction((UIComponent)playOnlineMenu, new UIMenuActionCloseMenuCallFunction.Function(__instance.OpenNoModsCreateGame)), UIAlign.Center, new Color(), false), true);
                }
                else
                {
                    playOnlineMenu.Add((UIComponent) new UIMenuItem("FIND GAME", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)playOnlineMenu, (UIComponent)joinGameMenu), UIAlign.Center, new Color(), false), true);
                    playOnlineMenu.Add((UIComponent) new UIMenuItem("CREATE GAME", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)playOnlineMenu, (UIComponent)hostGameMenu), UIAlign.Center, new Color(), false), true);
                }
                playOnlineMenu.Add((UIComponent) new UIMenuItem("BROWSE GAMES", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)playOnlineMenu, (UIComponent)browseGamesMenu), UIAlign.Center, new Color(), false), true);
                playOnlineMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                playOnlineMenu.Add((UIComponent) new UIMenuItem("CANCEL", (UIMenuAction) new UIMenuActionCloseMenuCallFunction(playOnlineGroup, new UIMenuActionCloseMenuCallFunction.Function(__instance.ClosedOnline)), UIAlign.Center, new Color(), true), true);
                playOnlineMenu.Close();
                playOnlineGroup.Add((UIComponent)playOnlineMenu, false);
                foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings)
                {
                    if (!onlineSetting.filterOnly)
                    {
                        hostGameMenu.AddMatchSetting(onlineSetting, false, true);
                    }
                }
                hostGameMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                hostGameMenu.Add((UIComponent) new UIMenuItem("CREATE GAME", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(playOnlineGroup, createGame), UIAlign.Center, new Color(), false), true);
                hostGameMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameMenu, (UIComponent)playOnlineMenu), UIAlign.Center, new Color(), true), true);
                hostGameMenu.Close();
                browseGamesMenu.Close();
                playOnlineGroup.Add((UIComponent)browseGamesMenu, false);
                playOnlineGroup.Add((UIComponent)hostGameMenu, false);
                miniHostGameMenu.AddMatchSetting(TeamSelect2.GetOnlineSetting("type"), false, true);
                miniHostGameMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                miniHostGameMenu.Add((UIComponent) new UIMenuItem("HOST GAME", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean((UIComponent)miniHostGameMenu, hostGame), UIAlign.Center, new Color(), false), true);
                miniHostGameMenu.Add((UIComponent) new UIMenuItem("CANCEL", (UIMenuAction) new UIMenuActionCloseMenu((UIComponent)miniHostGameMenu), UIAlign.Center, new Color(), true), true);
                miniHostGameMenu.Close();
                Level.Add((Thing)miniHostGameMenu);
                foreach (MatchSetting onlineSetting in TeamSelect2.onlineSettings)
                {
                    if (!onlineSetting.createOnly)
                    {
                        joinGameMenu.AddMatchSetting(onlineSetting, true, true);
                    }
                }
                joinGameMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                joinGameMenu.Add((UIComponent) new UIMenuItem("FIND GAME", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)joinGameMenu, (UIComponent)matchmaker), UIAlign.Center, new Color(), false), true);
                joinGameMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)joinGameMenu, (UIComponent)playOnlineMenu), UIAlign.Center, new Color(), true), true);
                joinGameMenu.Close();
                playOnlineGroup.Add((UIComponent)joinGameMenu, false);
                foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
                {
                    if (!(matchSetting.id == "workshopmaps") || Network.available)
                    {
                        filtersMenu.AddMatchSetting(matchSetting, true, true);
                    }
                }
                filtersMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                filtersMenu.Add((UIComponent) new UIModifierMenuItem((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)filtersMenu, (UIComponent)filterModifierMenu), UIAlign.Center, new Color(), false), true);
                filtersMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                filtersMenu.Add((UIComponent) new UIMenuItem("|DGBLUE|CLEAR FILTERS", (UIMenuAction) new UIMenuActionCallFunction(new UIMenuActionCallFunction.Function(__instance.ClearFilters)), UIAlign.Center, new Color(), false), true);
                filtersMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)filtersMenu, (UIComponent)joinGameMenu), UIAlign.Center, new Color(), true), true);
                filtersMenu.Close();
                playOnlineGroup.Add((UIComponent)filtersMenu, false);
                foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Modifier))
                {
                    filterModifierMenu.Add((UIComponent) new UIMenuItemToggle(unlock.shortName, (UIMenuAction)null, new FieldBinding((object)unlock, "enabled", 0.0f, 1f, 0.1f), new Color(), new FieldBinding((object)unlock, "filtered", 0.0f, 1f, 0.1f), (List <string>)null, false, false), true);
                }
                filterModifierMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                filterModifierMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)filterModifierMenu, (UIComponent)filtersMenu), UIAlign.Center, new Color(), true), true);
                filterModifierMenu.Close();
                playOnlineGroup.Add((UIComponent)filterModifierMenu, false);
                foreach (MatchSetting matchSetting in TeamSelect2.matchSettings)
                {
                    if (!(matchSetting.id == "workshopmaps") || Network.available)
                    {
                        hostGameSettingsMenu.AddMatchSetting(matchSetting, false, true);
                    }
                }
                hostGameSettingsMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                hostGameSettingsMenu.Add((UIComponent) new UIModifierMenuItem((UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameSettingsMenu, (UIComponent)hostGameModifierMenu), UIAlign.Center, new Color(), false), true);
                hostGameSettingsMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                hostGameSettingsMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameSettingsMenu, (UIComponent)hostGameMenu), UIAlign.Center, new Color(), true), true);
                hostGameSettingsMenu.Close();
                playOnlineGroup.Add((UIComponent)hostGameSettingsMenu, false);
                foreach (UnlockData unlock in Unlocks.GetUnlocks(UnlockType.Modifier))
                {
                    hostGameModifierMenu.Add((UIComponent) new UIMenuItemToggle(unlock.shortName, (UIMenuAction)null, new FieldBinding((object)unlock, "enabled", 0.0f, 1f, 0.1f), new Color(), (FieldBinding)null, (List <string>)null, false, false), true);
                }
                hostGameModifierMenu.Add((UIComponent) new UIText(" ", Color.White, UIAlign.Center, 0.0f, (InputProfile)null), true);
                hostGameModifierMenu.Add((UIComponent) new UIMenuItem("BACK", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)hostGameModifierMenu, (UIComponent)hostGameSettingsMenu), UIAlign.Center, new Color(), true), true);
                hostGameModifierMenu.Close();
                playOnlineGroup.Add((UIComponent)hostGameModifierMenu, false);
                matchmaker.Close();
                playOnlineGroup.Add((UIComponent)matchmaker, false);
                playOnlineGroup.Close();
                Level.Add((Thing)playOnlineGroup);
                Graphics.fade = 0.0f;
                Layer l = new Layer("HUD2", -85, new Camera(), false, new Vec2());

                l.camera.width  /= 2f;
                l.camera.height /= 2f;
                Layer.Add(l);
                Layer hud = Layer.HUD;

                Layer.HUD          = l;
                Editor.gamepadMode = true;
                Layer.HUD          = hud;

                // Start of setting private fields
                teamselect2type.GetField("_littleFont", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, littleFont);
                teamselect2type.GetField("_countdownScreen", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, countdownScreen);
                teamselect2type.GetField("_countdown", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, countdown);
                teamselect2type.GetField("_profiles", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, profiles);
                teamselect2type.GetField("_font", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, font);
                teamselect2type.GetField("_buttons", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, buttons);
                teamselect2type.GetField("_beam", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, beam);
                teamselect2type.GetField("_configGroup", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, configGroup);
                teamselect2type.GetField("_multiplayerMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, multiplayerMenu);
                teamselect2type.GetField("_modifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, modifierMenu);
                teamselect2type.GetField("_levelSelectMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, levelSelectMenu);
                teamselect2type.GetField("_playOnlineGroup", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, playOnlineGroup);
                teamselect2type.GetField("_playOnlineMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, playOnlineMenu);
                teamselect2type.GetField("_hostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGameMenu);
                teamselect2type.GetField("_browseGamesMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, browseGamesMenu);
                teamselect2type.GetField("_miniHostGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, miniHostGameMenu);
                teamselect2type.GetField("_joinGameMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, joinGameMenu);
                teamselect2type.GetField("_filtersMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, filtersMenu);
                teamselect2type.GetField("_filterModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, filterModifierMenu);
                teamselect2type.GetField("_matchmaker", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, matchmaker);
                teamselect2type.GetField("_hostGameSettingsMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGameSettingsMenu);
                teamselect2type.GetField("_hostGameModifierMenu", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGameModifierMenu);
                teamselect2type.GetField("_createGame", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, createGame);
                teamselect2type.GetField("_hostGame", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(__instance, hostGame);
                // End of setting private fields

                if (DuckNetwork.ShowUserXPGain() || !Unlockables.HasPendingUnlocks())
                {
                    return(false);
                }
                MonoMain.pauseMenu = (UIComponent) new UIUnlockBox(Unlockables.GetPendingUnlocks().ToList <Unlockable>(), Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 190f, -1f);

                return(false);
            }
Пример #13
0
        public Team FilterTeam(bool hardFilter = false)
        {
            Team        t           = null;
            Profile     _profile    = DuckNetwork.profiles[profileBoxNumber];
            TeamSelect2 current     = Level.current as TeamSelect2;
            ProfileBox2 box         = current.GetBox((byte)profileBoxNumber);
            HatSelector hatSelector = box._hatSelector;

            if (!Network.isActive)
            {
                t = AllTeams()[(int)_desiredTeamSelection];
            }
            int index = (int)_desiredTeamSelection;

            if (index >= AllTeams().Count)
            {
                index = ControllerNumber();
            }
            if (_profile != null && _profile.connection == DuckNetwork.localConnection && !hardFilter)
            {
                if (index >= Teams.core.teams.Count)
                {
                    Team allTeam = AllTeams()[index];
                    index = ControllerNumber();
                }
                t = AllTeams()[index];
            }
            Team allTeam1;

            if (_profile.connection == DuckNetwork.localConnection)
            {
                if (index >= Teams.core.teams.Count)
                {
                    Team allTeam2 = AllTeams()[index];
                    allTeam1 = AllTeams()[ControllerNumber()];
                    Team.MapFacade(localID, allTeam2);
                    Send.Message((NetMessage) new NMSpecialHat(allTeam2, localID));
                }
                else
                {
                    allTeam1 = AllTeams()[index];
                    Team.ClearFacade(_profile.steamID);
                    Send.Message((NetMessage) new NMSpecialHat((Team)null, localID));
                }
            }
            else
            {
                allTeam1 = AllTeams()[index];
            }
            t = allTeam1;

            if (hardFilter == true)
            {
                if (Network.isActive && box.duck != null)
                {
                    Send.Message(new NMSetTeam(box.duck.profile.networkIndex, (byte)Teams.IndexOf(t)));
                }
                if (t.hasHat)
                {
                    if (box.duck != null)
                    {
                        Hat equipment = box.duck.GetEquipment(typeof(Hat)) as Hat;
                        Hat hat       = (Hat) new TeamHat(0.0f, 0.0f, t);
                        Level.Add((Thing)hat);
                        box.duck.Equip((Equipment)hat, false, false);
                        box.duck.Fondle((Thing)hat);
                        if (hatSelector.hat != null)
                        {
                            Level.Remove((Thing)hatSelector.hat);
                        }
                        hatSelector.hat = hat;
                        if (equipment != null)
                        {
                            Level.Remove((Thing)equipment);
                        }
                    }
                    else if (hatSelector.hat != null)
                    {
                        Level.Remove((Thing)hatSelector.hat);
                    }
                }
                else
                {
                    if (hatSelector.hat != null)
                    {
                        Level.Remove((Thing)hatSelector.hat);
                    }
                    hatSelector.hat = (Hat)null;
                    if (box.duck != null)
                    {
                        Hat equipment = box.duck.GetEquipment(typeof(Hat)) as Hat;
                        if (equipment != null)
                        {
                            box.duck.Unequip((Equipment)equipment, false);
                            Level.Remove((Thing)equipment);
                        }
                    }
                }
                if (_desiredTeamSelection <= 7)
                {
                    _desiredTeamSelection = 0;
                }
            }
            return(t);
        }
Пример #14
0
        public override void Initialize()
        {
            TeamSelect2.DefaultSettings();
            base.Initialize();
            this.UpdateDefault();
            bool flag = true;

            foreach (Profile prof in Profiles.active)
            {
                if (flag)
                {
                    flag = false;
                }
                else
                {
                    if (prof.team != null)
                    {
                        prof.team.Leave(prof);
                    }
                    prof.inputProfile = (InputProfile)null;
                }
            }
            this._pendingSpawns = new Deathmatch((Level)this).SpawnPlayers();
            this._pendingSpawns = this._pendingSpawns.OrderBy <Duck, float>((Func <Duck, float>)(sp => sp.x)).ToList <Duck>();
            foreach (Duck pendingSpawn in this._pendingSpawns)
            {
                this.followCam.Add((Thing)pendingSpawn);
                ((ArcadeHatConsole)Level.First <ArcadeHatConsole>())?.MakeHatSelector(pendingSpawn);
            }
            this.followCam.Adjust();
            foreach (ArcadeMachine arcadeMachine in this.things[typeof(ArcadeMachine)])
            {
                this._challenges.Add(arcadeMachine);
            }
            Profiles.active[0].ticketCount = Challenges.GetTicketCount(Profiles.active[0]);
            if (Profiles.active[0].ticketCount < 0)
            {
                Profiles.active[0].ticketCount = 0;
            }
            foreach (ArcadeFrame arcadeFrame in this.things[typeof(ArcadeFrame)])
            {
                this._frames.Add(arcadeFrame);
            }
            foreach (ChallengeSaveData challengeSaveData in Challenges.GetAllSaveData())
            {
                if (challengeSaveData.frameID != "")
                {
                    ArcadeFrame frame = this.GetFrame(challengeSaveData.frameID);
                    if (frame != null)
                    {
                        frame.saveData = challengeSaveData;
                    }
                }
            }
            foreach (ArcadeMachine challenge in this._challenges)
            {
                challenge.unlocked = challenge.CheckUnlocked(false);
            }
            this._hud       = new ArcadeHUD();
            this._hud.alpha = 0.0f;
            Level.Add((Thing)this._hud);
            this._unlockScreen       = new UnlockScreen();
            this._unlockScreen.alpha = 0.0f;
            Level.Add((Thing)this._unlockScreen);
            this._pauseGroup  = new UIComponent(Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 0.0f, 0.0f);
            this._pauseMenu   = new UIMenu("@LWING@CHALLENGE MODE@RWING@", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@DPAD@MOVE  @SELECT@SELECT");
            this._confirmMenu = new UIMenu("REALLY QUIT?", Layer.HUD.camera.width / 2f, Layer.HUD.camera.height / 2f, 160f, conString: "@SELECT@SELECT");
            UIDivider uiDivider = new UIDivider(true, 0.8f);

            uiDivider.leftSection.Add((UIComponent) new UIMenuItem("RESUME", (UIMenuAction) new UIMenuActionCloseMenu(this._pauseGroup), UIAlign.Left), true);
            uiDivider.leftSection.Add((UIComponent) new UIMenuItem("OPTIONS", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._pauseMenu, (UIComponent)Options.optionsMenu), UIAlign.Left), true);
            uiDivider.leftSection.Add((UIComponent) new UIMenuItem("QUIT", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._pauseMenu, (UIComponent)this._confirmMenu), UIAlign.Left), true);
            uiDivider.rightSection.Add((UIComponent) new UIImage("pauseIcons", UIAlign.Right), true);
            this._pauseMenu.Add((UIComponent)uiDivider, true);
            this._pauseMenu.Close();
            this._pauseGroup.Add((UIComponent)this._pauseMenu, false);
            this._pauseGroup.Add((UIComponent)Options.optionsMenu, false);
            Options.openOnClose = this._pauseMenu;
            this._confirmMenu.Add((UIComponent) new UIMenuItem("NO!", (UIMenuAction) new UIMenuActionOpenMenu((UIComponent)this._confirmMenu, (UIComponent)this._pauseMenu)), true);
            this._confirmMenu.Add((UIComponent) new UIMenuItem("YES!", (UIMenuAction) new UIMenuActionCloseMenuSetBoolean(this._pauseGroup, this._quit)), true);
            this._confirmMenu.Close();
            this._pauseGroup.Add((UIComponent)this._confirmMenu, false);
            this._pauseGroup.Close();
            Level.Add((Thing)this._pauseGroup);
            this._prizeTable = this.things[typeof(PrizeTable)].FirstOrDefault <Thing>() as PrizeTable;
            if (this._prizeTable == null)
            {
                this._prizeTable = new PrizeTable(730f, 124f);
            }
            Chancy.activeChallenge    = (ChallengeData)null;
            Chancy.atCounter          = true;
            Chancy.lookingAtChallenge = false;
            Graphics.fade             = 1f;
            this.basementWasUnlocked  = Unlocks.IsUnlocked("BASEMENTKEY", Profiles.active[0]);
            Level.Add((Thing)this._prizeTable);
            Music.Play("Arcade");
        }
        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;
        }
        public static NetMessage OnMessageFromNewClient(NetMessage m)
        {
            if (Network.isServer)
            {
                if (m is NMRequestJoin)
                {
                    if (DuckNetwork.inGame)
                    {
                        return((NetMessage) new NMGameInProgress());
                    }
                    NMRequestJoin nmRequestJoin = m as NMRequestJoin;
//                    DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|Join attempt from " + nmRequestJoin.name, -1);
                    NMVersionMismatch.Type code = DuckNetwork.CheckVersion(nmRequestJoin.id);
                    if (code != NMVersionMismatch.Type.Match)
                    {
//                        DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|" + nmRequestJoin.name + " had a version mismatch.", -1);
//                        return (NetMessage)new NMVersionMismatch(code, DG.version);
                        return((NetMessage) new NMVersionMismatch(code, Assembly.GetEntryAssembly().GetName().Version.ToString()));
                    }
                    Type       methodtype    = typeof(DuckNetwork);
                    MethodInfo createProfile = methodtype.GetMethod("CreateProfile", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);

//                    Profile profile = DuckNetwork.CreateProfile(m.connection, nmRequestJoin.name, -1, (InputProfile)null, nmRequestJoin.hasCustomHats, nmRequestJoin.wasInvited, false);
                    Profile profile = (Profile)createProfile.Invoke(null, new object[] { m.connection, nmRequestJoin.name, -1, (InputProfile)null, nmRequestJoin.hasCustomHats, nmRequestJoin.wasInvited, false });

                    if (profile == null)
                    {
//                        DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|" + nmRequestJoin.name + " could not join, server is full.", -1);
                        return((NetMessage) new NMServerFull());
                    }
                    profile.flippers      = nmRequestJoin.flippers;
                    profile.networkStatus = DuckNetStatus.WaitingForLoadingToBeFinished;
                    _core.status          = DuckNetStatus.Connected;

                    TeamSelect2Edits.OnNetworkConnecting(profile);

                    DuckNetwork.SendNewProfile(profile, m.connection, false);

                    // More slots so we need bigger method to handle them
                    Send.Message(new NMChangeSlotsEdits((byte)DuckNetwork.profiles[0].slotType, (byte)DuckNetwork.profiles[1].slotType, (byte)DuckNetwork.profiles[2].slotType, (byte)DuckNetwork.profiles[3].slotType, (byte)DuckNetwork.profiles[4].slotType, (byte)DuckNetwork.profiles[5].slotType, (byte)DuckNetwork.profiles[6].slotType, (byte)DuckNetwork.profiles[7].slotType), m.connection);
                    TeamSelect2.SendMatchSettings(m.connection, true);
                    return((NetMessage)null);
                }
                if (m is NMMessageIgnored)
                {
                    return((NetMessage)null);
                }
            }
            else
            {
                if (m is NMRequestJoin)
                {
//                    DevConsole.Log(DCSection.DuckNet, "|DGYELLOW|Another computer has requested a matchmaking connection.", -1);
                    return((NetMessage) new NMGameInProgress());
                }
                if (m is NMMessageIgnored)
                {
                    return((NetMessage)null);
                }
            }
            return((NetMessage) new NMMessageIgnored());
        }