예제 #1
0
        private async void GetLevelEntitlement(IConnectedPlayer player)
        {
            if (entitlementCts != null)
            {
                entitlementCts.Cancel();
            }
            entitlementCts = new CancellationTokenSource();

            string?levelId = _playersDataModel.GetPlayerBeatmapLevel(_playersDataModel.hostUserId)?.levelID;

            if (levelId == null)
            {
                return;
            }

            lastLevelId = levelId;

            bool needsRpc = false;
            Task <EntitlementsStatus> entitlement = player.isMe ?
                                                    _entitlementChecker.GetEntitlementStatus(levelId) :
                                                    _entitlementChecker.GetTcsTaskCanPlayerPlayLevel(player, levelId, entitlementCts.Token, out needsRpc);

            if (needsRpc)
            {
                _menuRpcManager.GetIsEntitledToLevel(levelId);
            }
            SetLevelEntitlement(player, await entitlement);
        }
        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;
                                });
                            });
                        }
                    }
                }
            }
        }
예제 #3
0
        private async void GetLevelEntitlement(IConnectedPlayer player)
        {
            if (entitlementCts != null)
            {
                entitlementCts.Cancel();
            }
            entitlementCts = new CancellationTokenSource();

            string?levelId = _playersDataModel.GetPlayerBeatmapLevel(_playersDataModel.hostUserId)?.levelID;

            if (levelId == null)
            {
                return;
            }

            lastLevelId = levelId;
            EntitlementsStatus entitlement = player.isMe ? await _entitlementChecker.GetEntitlementStatus(levelId) : await _entitlementChecker.GetTcsTaskCanPlayerPlayLevel(player, levelId, entitlementCts.Token, out _);

            SetLevelEntitlement(player, entitlement);
        }