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(); }