static void Postfix(List <IConnectedPlayer> sortedPlayers, ILobbyPlayersDataModel lobbyPlayersDataModel, GameServerPlayersTableView __instance)
        {
            IPreviewBeatmapLevel hostBeatmap = lobbyPlayersDataModel.GetPlayerBeatmapLevel(lobbyPlayersDataModel.hostUserId);

            if (hostBeatmap != null && hostBeatmap is PreviewBeatmapStub hostBeatmapStub)
            {
                TableView tableView = __instance.GetField <TableView, GameServerPlayersTableView>("_tableView");
                foreach (TableCell cell in tableView.visibleCells)
                {
                    if (cell is GameServerPlayerTableCell playerCell)
                    {
                        Image             background      = playerCell.GetField <Image, GameServerPlayerTableCell>("_localPlayerBackgroundImage");
                        CurvedTextMeshPro emptySuggestion = playerCell.GetField <CurvedTextMeshPro, GameServerPlayerTableCell>("_emptySuggestedLevelText");
                        CurvedTextMeshPro suggestion      = playerCell.GetField <CurvedTextMeshPro, GameServerPlayerTableCell>("_suggestedLevelText");
                        IConnectedPlayer  player          = sortedPlayers[playerCell.idx];
                        Color             backgroundColor = new Color();

                        if (player.isConnectionOwner)
                        {
                            suggestion.gameObject.SetActive(false);
                            emptySuggestion.gameObject.SetActive(true);
                            emptySuggestion.text = "Loading...";
                            hostBeatmapStub.isDownloadable.ContinueWith(r =>
                            {
                                HMMainThreadDispatcher.instance.Enqueue(() =>
                                {
                                    suggestion.gameObject.SetActive(true);
                                    emptySuggestion.gameObject.SetActive(false);
                                });
                            });
                        }
                        // TODO: check merge
                        background.enabled = true;
                        if (player.HasState("beatmap_downloaded") || player.HasState("start_primed"))
                        {
                            backgroundColor   = green;
                            backgroundColor.a = player.isMe ? 0.4f : 0.1f;
                            background.color  = backgroundColor;
                        }
                        else
                        {
                            hostBeatmapStub.isDownloadable.ContinueWith(r =>
                            {
                                bool downloadable = r.Result;
                                backgroundColor   = downloadable ? yellow : red;
                                backgroundColor.a = player.isMe ? 0.4f : 0.1f;
                                HMMainThreadDispatcher.instance.Enqueue(() =>
                                {
                                    background.color = backgroundColor;
                                });
                            });
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Replaces selected gameplay modifiers if freemod is enabled.
 /// </summary>
 static void Postfix(string userId, ref ILobbyPlayersDataModel ____lobbyPlayersDataModel, ref ModifiersSelectionView ____modifiersSelectionView)
 {
     if (userId == ____lobbyPlayersDataModel.localUserId && MPState.FreeModEnabled)
     {
         GameplayModifiers gameplayModifiers = ____lobbyPlayersDataModel.GetPlayerGameplayModifiers(userId);
         if (gameplayModifiers != null)
         {
             ____modifiersSelectionView.SetGameplayModifiers(gameplayModifiers);
         }
     }
 }
Example #3
0
 internal void Inject(NetworkPlayerEntitlementChecker entitlementChecker, ILobbyPlayersDataModel playersDataModel, IMenuRpcManager menuRpcManager)
 {
     _entitlementChecker = entitlementChecker;
     _playersDataModel   = playersDataModel;
     _menuRpcManager     = menuRpcManager;
 }