Beispiel #1
0
        private void Init(CountersData data)
        {
            _scoreController = data.ScoreController;
            PlayerDataModelSO player = data.PlayerData;

            gameplayModsModel = data.ModifiersData;
            gameplayMods      = data.PlayerData.playerData.gameplayModifiers;
            IDifficultyBeatmap beatmap = data.GCSSD.difficultyBeatmap;

            stats = player.playerData.GetPlayerLevelStatsData(
                beatmap.level.levelID, beatmap.difficulty, beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
            int maxRawScore = ScoreController.MaxRawScoreForNumberOfNotes(beatmap.beatmapData.notesCount);

            _maxPossibleScore = Mathf.RoundToInt(maxRawScore * gameplayModsModel.GetTotalMultiplier(gameplayMods));
            beginningPB       = stats.highScore / (float)_maxPossibleScore;
            highScore         = stats.highScore;

            Vector3 position = CountersController.DeterminePosition(gameObject, settings.Position, settings.Distance);

            TextHelper.CreateText(out _PbTrackerText, position);
            _PbTrackerText.fontSize  = settings.TextSize;
            _PbTrackerText.color     = Color.white;
            _PbTrackerText.alignment = TextAlignmentOptions.Center;

            _scoreController.scoreDidChangeEvent += UpdateScore;

            SetPersonalBest(beginningPB);

            if (settings.UnderScore)
            {
                StartCoroutine(WaitForScoreCounter());
            }
        }
        /// <summary>
        /// Update the gameplay play counts.
        /// </summary>
        /// <param name="gameplayMode"></param>
        private void UpdatePlayCounts()
        {
            // Build a map of levelId to sum of all playcounts and sort.
            PlayerDataModelSO playerData = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            foreach (KeyValuePair <string, List <BeatmapLevelSO> > entry in _levelPackToSongs)
            {
                foreach (var level in entry.Value)
                {
                    if (!_levelIdToPlayCount.ContainsKey(level.levelID))
                    {
                        // Skip folders
                        int playCountSum = 0;
                        foreach (IDifficultyBeatmapSet set in level.difficultyBeatmapSets)
                        {
                            foreach (IDifficultyBeatmap beatmap in set.difficultyBeatmaps)
                            {
                                PlayerLevelStatsData stats = playerData.currentLocalPlayer.GetPlayerLevelStatsData(level.levelID, beatmap.difficulty, set.beatmapCharacteristic);
                                playCountSum += stats.playCount;
                            }
                        }
                        _levelIdToPlayCount.Add(level.levelID, playCountSum);
                    }
                }
            }
        }
        public void SongFinished(StandardLevelSceneSetupDataSO sender, LevelCompletionResults levelCompletionResults, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers)
        {
            try
            {
                if (sender == null || levelCompletionResults == null || difficultyBeatmap == null || gameplayModifiers == null)
                {
                    return;
                }
                Logger.Debug("Finished song: " + levelCompletionResults.levelEndStateType + " - " + levelCompletionResults.songDuration + " - - " + levelCompletionResults.endSongTime);

                PlayerDataModelSO _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();
                _playerDataModel.currentLocalPlayer.playerAllOverallStatsData.soloFreePlayOverallStatsData.UpdateWithLevelCompletionResults(levelCompletionResults);
                _playerDataModel.Save();
                if (levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Failed && levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Cleared)
                {
                    return;
                }

                PlayerDataModelSO.LocalPlayer currentLocalPlayer = _playerDataModel.currentLocalPlayer;
                bool                 cleared              = levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;
                string               levelID              = difficultyBeatmap.level.levelID;
                BeatmapDifficulty    difficulty           = difficultyBeatmap.difficulty;
                PlayerLevelStatsData playerLevelStatsData = currentLocalPlayer.GetPlayerLevelStatsData(levelID, difficulty);
                bool                 newHighScore         = playerLevelStatsData.highScore < levelCompletionResults.score;
                playerLevelStatsData.IncreaseNumberOfGameplays();
                if (cleared)
                {
                    playerLevelStatsData.UpdateScoreData(levelCompletionResults.score, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                    Resources.FindObjectsOfTypeAll <PlatformLeaderboardsModel>().First().AddScore(difficultyBeatmap, levelCompletionResults.unmodifiedScore, gameplayModifiers);
                }
            } catch (Exception e)
            {
                Data.Logger.Error(e);
            }
        }
Beispiel #4
0
        public void SetupViewController()
        {
            playNowButtonGlow = playNowButton.GetComponent <Glowable>();

            levelDetailsRect.gameObject.AddComponent <Mask>();

            Image maskImage = levelDetailsRect.gameObject.AddComponent <Image>();

            maskImage.material = Sprites.NoGlowMat;
            maskImage.sprite   = Resources.FindObjectsOfTypeAll <Sprite>().First(x => x.name == "RoundRectPanel");
            maskImage.type     = Image.Type.Sliced;
            maskImage.color    = new Color(0f, 0f, 0f, 0.25f);

            levelCoverImage.color = new Color(0.5f, 0.5f, 0.5f, 0.5f);

            progressBarBG.color  = new Color(1f, 1f, 1f, 0.2f);
            progressBarTop.color = new Color(1f, 1f, 1f, 1f);

            //_beatmapLevelsModel = Resources.FindObjectsOfTypeAll<BeatmapLevelsModel>().First();

            _defaultArtworkTexture = Resources.FindObjectsOfTypeAll <Texture2D>().First(x => x.name == "DefaultSongArtwork");

            _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();

            leaderboardTableView.GetComponent <TableView>().RemoveReusableCells("Cell");

            if (selectedLevel != null)
            {
                SetSong(selectedLevel, selectedBeatmapCharacteristic, selectedDifficulty);
            }
        }
        /// <summary>
        /// Migrate old favorites into new system.
        /// </summary>
        public static void MigrateFavorites()
        {
            String migratedPlaylistPath = Path.Combine(Environment.CurrentDirectory, "Playlists", MigratedFavoritesPlaylistName);
            String oldFavoritesPath     = Path.Combine(Environment.CurrentDirectory, "Playlists", DefaultConvertedFavoritesPlaylistName);

            // Skip if already migrated or if the song browser favorites do not exist
            if (!File.Exists(oldFavoritesPath) || File.Exists(migratedPlaylistPath))
            {
                return;
            }

            Logger.Info("Migrating [{0}] into the In-Game favorites.", oldFavoritesPath);

            Playlist          oldFavorites = Playlist.LoadPlaylist(oldFavoritesPath);
            PlayerDataModelSO playerData   = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            foreach (PlaylistSong song in oldFavorites.songs)
            {
                string levelID = CustomLevelLoader.kCustomLevelPrefixId + song.hash;
                Logger.Info("Migrating song into ingame favorites: {0}", levelID);
                playerData.playerData.favoritesLevelIds.Add(levelID);
            }

            Logger.Info("Moving [{0}->{1}] into the In-Game favorites.", oldFavoritesPath, migratedPlaylistPath);
            File.Move(oldFavoritesPath, migratedPlaylistPath);

            playerData.Save();
        }
        /// <summary>
        /// Update the gameplay play counts.
        /// </summary>
        /// <param name="gameplayMode"></param>
        private void UpdatePlayCounts()
        {
            // Build a map of levelId to sum of all playcounts and sort.
            PlayerDataModelSO playerData = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();
            IEnumerable <BeatmapDifficulty> difficultyIterator = Enum.GetValues(typeof(BeatmapDifficulty)).Cast <BeatmapDifficulty>();

            foreach (var level in _originalSongs)
            {
                if (!_levelIdToPlayCount.ContainsKey(level.levelID))
                {
                    // Skip folders
                    if (level.levelID.StartsWith("Folder_"))
                    {
                        _levelIdToPlayCount.Add(level.levelID, 0);
                    }
                    else
                    {
                        int playCountSum = 0;
                        foreach (BeatmapDifficulty difficulty in difficultyIterator)
                        {
                            PlayerLevelStatsData stats = playerData.currentLocalPlayer.GetPlayerLevelStatsData(level.levelID, difficulty);
                            playCountSum += stats.playCount;
                        }
                        _levelIdToPlayCount.Add(level.levelID, playCountSum);
                    }
                }
            }
        }
Beispiel #7
0
        protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            base.DidActivate(firstActivation, type);

            if (firstActivation)
            {
                if (Plugin.DownloaderExists)
                {
                    downloader = new BeatSaverDownloaderInterop();
                    if (downloader == null)
                    {
                        Plugin.log.Warn($"{nameof(BeatSaverDownloaderInterop)} could not be created.");
                    }
                    else
                    {
                        MoreSongsAvailable = downloader.CanCreate;
                        Plugin.log.Debug($"{nameof(MoreSongsAvailable)} is {MoreSongsAvailable}");
                    }
                }
                else
                {
                    Plugin.log.Warn($"BeatSaverDownloader not found, More Songs button won't be created.");
                    MoreSongsAvailable = false;
                }

                _songsTableView.tableView.didSelectCellWithIdxEvent += SongsTableView_DidSelectRow;
                _songsTableView.tableView.dataSource = this;

                _playerDataModel        = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();
                _additionalContentModel = Resources.FindObjectsOfTypeAll <AdditionalContentModel>().First();
            }

            SelectTopButtons(TopButtonsState.Select);
        }
Beispiel #8
0
        public void SetupViewController()
        {
            playButtonGlow = playButton.GetComponent <Glowable>();

            levelDetailsRect.gameObject.AddComponent <Mask>();

            Image maskImage = levelDetailsRect.gameObject.AddComponent <Image>();

            maskImage.material = Sprites.NoGlowMat;
            maskImage.sprite   = Resources.FindObjectsOfTypeAll <Sprite>().First(x => x.name == "RoundRectPanel");
            maskImage.type     = Image.Type.Sliced;
            maskImage.color    = new Color(0f, 0f, 0f, 0.25f);

            levelCoverImage.color = new Color(0.5f, 0.5f, 0.5f, 0.5f);

            progressBarBG.color  = new Color(1f, 1f, 1f, 0.2f);
            progressBarTop.color = new Color(1f, 1f, 1f, 1f);

            charactertisticControlBlocker.color = new Color(1f, 1f, 1f, 0f);
            difficultyControlBlocker.color      = new Color(1f, 1f, 1f, 0f);

            cancellationToken = new CancellationTokenSource();

            _defaultArtworkTexture = Resources.FindObjectsOfTypeAll <Texture2D>().First(x => x.name == "DefaultSongArtwork");

            _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();
        }
Beispiel #9
0
        public void SongFinished(StandardLevelScenesTransitionSetupDataSO sender, LevelCompletionResults levelCompletionResults, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers, bool practice)
        {
            if (Client.Instance.InRadioMode)
            {
                PluginUI.instance.radioFlowCoordinator.lastDifficulty = difficultyBeatmap;
                PluginUI.instance.radioFlowCoordinator.lastResults    = levelCompletionResults;
            }

            if (Config.Instance.SpectatorMode || Client.disableScoreSubmission || ScoreSubmission.Disabled || ScoreSubmission.ProlongedDisabled)
            {
                List <string> reasons = new List <string>();

                if (Config.Instance.SpectatorMode)
                {
                    reasons.Add("Spectator mode");
                }
                if (Client.disableScoreSubmission)
                {
                    reasons.Add("Multiplayer score submission disabled by another mod");
                }
                if (ScoreSubmission.Disabled)
                {
                    reasons.Add("Score submission is disabled by " + ScoreSubmission.ModString);
                }
                if (ScoreSubmission.ProlongedDisabled)
                {
                    reasons.Add("Score submission is disabled for a prolonged time by " + ScoreSubmission.ProlongedModString);
                }

                Misc.Logger.Warning("\nScore submission is disabled! Reason:\n" + string.Join(",\n", reasons));
                return;
            }

            PlayerDataModelSO _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();

            _playerDataModel.currentLocalPlayer.playerAllOverallStatsData.soloFreePlayOverallStatsData.UpdateWithLevelCompletionResults(levelCompletionResults);
            _playerDataModel.Save();
            if (levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Failed && levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Cleared)
            {
                return;
            }

            PlayerDataModelSO.LocalPlayer currentLocalPlayer = _playerDataModel.currentLocalPlayer;
            bool                    cleared               = levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;
            string                  levelID               = difficultyBeatmap.level.levelID;
            BeatmapDifficulty       difficulty            = difficultyBeatmap.difficulty;
            BeatmapCharacteristicSO beatmapCharacteristic = difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic;
            PlayerLevelStatsData    playerLevelStatsData  = currentLocalPlayer.GetPlayerLevelStatsData(levelID, difficulty, beatmapCharacteristic);
            bool                    newHighScore          = playerLevelStatsData.highScore < levelCompletionResults.score;

            playerLevelStatsData.IncreaseNumberOfGameplays();
            if (cleared)
            {
                Misc.Logger.Info("Submitting score...");
                playerLevelStatsData.UpdateScoreData(levelCompletionResults.score, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                Resources.FindObjectsOfTypeAll <PlatformLeaderboardsModel>().First().AddScore(difficultyBeatmap, levelCompletionResults.unmodifiedScore, gameplayModifiers);
                Misc.Logger.Info("Score submitted!");
            }
        }
Beispiel #10
0
        /// <summary>
        /// Filter songs based on playerdata favorites.
        /// </summary>
        private List <IPreviewBeatmapLevel> FilterFavorites(List <IPreviewBeatmapLevel> levels)
        {
            Logger.Info("Filtering song list as favorites playlist...");

            PlayerDataModelSO playerData = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            return(levels.Where(x => playerData.playerData.favoritesLevelIds.Contains(x.levelID)).ToList());
        }
        static bool Prefix(MissionLevelScenesTransitionSetupDataSO missionLevelScenesTransitionSetupData, MissionCompletionResults missionCompletionResults, CampaignFlowCoordinator __instance, MissionSelectionNavigationController ____missionSelectionNavigationController)
        {
            if (!(____missionSelectionNavigationController.selectedMissionNode.missionData is CustomMissionDataSO))
            {
                return(true);
            }
            ChallengeExternalModifiers.onChallengeEnd?.Invoke();
            if (missionCompletionResults.levelCompletionResults.levelEndAction == LevelCompletionResults.LevelEndAction.Restart)
            {
                ____missionSelectionNavigationController.GetPrivateField <Action <MissionSelectionNavigationController> >("didPressPlayButtonEvent")(____missionSelectionNavigationController);
                return(false);
            }
            if (missionCompletionResults.levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared && missionCompletionResults.IsMissionComplete)
            {
                CustomMissionDataSO customMissionData = ____missionSelectionNavigationController.selectedMissionNode.missionData as CustomMissionDataSO;
                Campaign            campaign          = customMissionData.campaign;
                Challenge           challenge         = customMissionData.challenge;
                foreach (UnlockableItem item in challenge.unlockableItems)
                {
                    try
                    {
                        item.UnlockItem(campaign.path);
                    } catch (Exception ex)
                    {
                        Console.WriteLine("Failed to unlock item: " + item.fileName + " - Exception: " + ex.Message);
                    }
                }
                UnlockedItemsViewController unlockedItemsViewController = Resources.FindObjectsOfTypeAll <UnlockedItemsViewController>().First();
                unlockedItemsViewController.items = challenge.unlockableItems;
                unlockedItemsViewController.index = 0;
                if (unlockedItemsViewController.items.Count > 0)
                {
                    __instance.InvokeMethod("SetBottomScreenViewController", new object[] { unlockedItemsViewController, false });
                }
                if (challenge.unlockMap)
                {
                    UnlockedMaps.CompletedChallenge(challenge.name);
                }
                //Score submission
                if (customMissionData.gameplayModifiers.songSpeedMul == 1f && customMissionData.gameplayModifiers.fastNotes == false && customMissionData.gameplayModifiers.failOnSaberClash == false)
                {
                    SoloFreePlayFlowCoordinator freePlayCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First();

                    PlayerDataModelSO dataModel = freePlayCoordinator.GetPrivateField <PlayerDataModelSO>("_playerDataModel");

                    PlayerData             currentLocalPlayer     = dataModel.playerData;
                    IDifficultyBeatmap     difficultyBeatmap      = Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded(customMissionData.customLevel.levelID).beatmapLevelData.GetDifficultyBeatmap(customMissionData.beatmapCharacteristic, customMissionData.beatmapDifficulty);
                    PlayerLevelStatsData   playerLevelStatsData   = currentLocalPlayer.GetPlayerLevelStatsData(difficultyBeatmap.level.levelID, difficultyBeatmap.difficulty, difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic);
                    LevelCompletionResults levelCompletionResults = missionCompletionResults.levelCompletionResults;
                    playerLevelStatsData.UpdateScoreData(levelCompletionResults.modifiedScore, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                    //todo Need change???
                    //freePlayCoordinator.GetPrivateField<PlatformLeaderboardsModel>("_platformLeaderboardsModel").AddScoreFromComletionResults(difficultyBeatmap, levelCompletionResults);
                }

                __instance.StartCoroutine(CustomCampaignLeaderboard.SubmitScore(challenge, missionCompletionResults));
            }
            return(true);
        }
 public CountersData()
 {
     ScoreController         = Resources.FindObjectsOfTypeAll <ScoreController>().First();
     PlayerController        = Resources.FindObjectsOfTypeAll <PlayerController>().First();
     AudioTimeSyncController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().First();
     PlayerData    = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();
     ModifiersData = Resources.FindObjectsOfTypeAll <GameplayModifiersModelSO>().First();
     GCSSD         = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData; //By the time all of these load, so should GCSSD.
 }
Beispiel #13
0
        private static void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            //var originObject = GameObject.Find("Origin");
            //if (originObject != null)
            //{
            //	_originTransform = originObject.transform;
            //}
        }
Beispiel #14
0
        public static float GetPlayerHeight()
        {
            if (!_playerDataModel)
            {
                _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();
            }

            _lastPlayerHeight = !_playerDataModel ? _lastPlayerHeight : _playerDataModel.playerData.playerSpecificSettings.playerHeight;

            return(_lastPlayerHeight);
        }
        /// <summary>
        /// Update the gameplay play counts.
        /// </summary>
        /// <param name="gameplayMode"></param>
        private void UpdatePlayCounts()
        {
            // Reset current playcounts
            _levelIdToPlayCount = new Dictionary <string, int>();

            // Build a map of levelId to sum of all playcounts and sort.
            PlayerDataModelSO playerData = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            foreach (var levelData in playerData.playerData.levelsStatsData)
            {
                if (!_levelIdToPlayCount.ContainsKey(levelData.levelID))
                {
                    _levelIdToPlayCount.Add(levelData.levelID, 0);
                }

                _levelIdToPlayCount[levelData.levelID] += levelData.playCount;
            }
        }
Beispiel #16
0
        public static void GetSongInfo()
        {
            if (_mainGameSceneSetupData == null)
            {
                _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().FirstOrDefault();
            }
            //Get notes count
            noteCount = _mainGameSceneSetupData.difficultyBeatmap.beatmapData.notesCount;
            PlayerDataModelSO    playerData      = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();
            PlayerLevelStatsData playerLevelData = playerData.currentLocalPlayer.GetPlayerLevelStatsData(_mainGameSceneSetupData.difficultyBeatmap.level.levelID, _mainGameSceneSetupData.difficultyBeatmap.difficulty);

            //Get Player Score
            if (playerScore == 0)
            {
                Log("Attempting to grab Local Score");
                playerScore = playerLevelData.validScore ? playerLevelData.highScore : 0;
            }


            CalculatePercentage();
        }
        private IEnumerator WaitForSabers(GameObject saberRoot)
        {
            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <Saber>().Any()));

            PlayerDataModelSO playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().FirstOrDefault();

            IEnumerable <Saber> defaultSabers = Resources.FindObjectsOfTypeAll <Saber>();

            foreach (Saber defaultSaber in defaultSabers)
            {
                Logger.log.Debug($"Hiding default '{defaultSaber.saberType}'");
                IEnumerable <MeshFilter> meshFilters = defaultSaber.transform.GetComponentsInChildren <MeshFilter>();
                foreach (MeshFilter meshFilter in meshFilters)
                {
                    meshFilter.gameObject.SetActive(!saberRoot);

                    MeshFilter filter = meshFilter.GetComponentInChildren <MeshFilter>();
                    if (filter)
                    {
                        filter.gameObject.SetActive(!saberRoot);
                    }
                }

                Logger.log.Debug($"Attaching custom saber to '{defaultSaber.saberType}'");
                if (defaultSaber.saberType == Saber.SaberType.SaberA)
                {
                    PrepareSaber(saberRoot, defaultSaber, leftSaber);
                    ApplyColorsToSaber(leftSaber, colorManager.ColorForSaberType(defaultSaber.saberType));
                }
                else if (defaultSaber.saberType == Saber.SaberType.SaberB)
                {
                    PrepareSaber(saberRoot, defaultSaber, rightSaber);
                    ApplyColorsToSaber(rightSaber, colorManager.ColorForSaberType(defaultSaber.saberType));
                }
            }
        }
Beispiel #18
0
        public void SongFinished(StandardLevelSceneSetupDataSO sender, LevelCompletionResults levelCompletionResults, IDifficultyBeatmap difficultyBeatmap, GameplayModifiers gameplayModifiers, bool practice)
        {
            if (Client.Instance.InRadioMode)
            {
                PluginUI.instance.radioFlowCoordinator.lastDifficulty = difficultyBeatmap;
                PluginUI.instance.radioFlowCoordinator.lastResults    = levelCompletionResults;
            }

            if (Config.Instance.SpectatorMode || Client.disableScoreSubmission || ScoreSubmission.Disabled || ScoreSubmission.ProlongedDisabled)
            {
                return;
            }

            PlayerDataModelSO _playerDataModel = Resources.FindObjectsOfTypeAll <PlayerDataModelSO>().First();

            _playerDataModel.currentLocalPlayer.playerAllOverallStatsData.soloFreePlayOverallStatsData.UpdateWithLevelCompletionResults(levelCompletionResults);
            _playerDataModel.Save();
            if (levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Failed && levelCompletionResults.levelEndStateType != LevelCompletionResults.LevelEndStateType.Cleared)
            {
                return;
            }

            PlayerDataModelSO.LocalPlayer currentLocalPlayer = _playerDataModel.currentLocalPlayer;
            bool                 cleared              = levelCompletionResults.levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared;
            string               levelID              = difficultyBeatmap.level.levelID;
            BeatmapDifficulty    difficulty           = difficultyBeatmap.difficulty;
            PlayerLevelStatsData playerLevelStatsData = currentLocalPlayer.GetPlayerLevelStatsData(levelID, difficulty);
            bool                 newHighScore         = playerLevelStatsData.highScore < levelCompletionResults.score;

            playerLevelStatsData.IncreaseNumberOfGameplays();
            if (cleared)
            {
                playerLevelStatsData.UpdateScoreData(levelCompletionResults.score, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank);
                Resources.FindObjectsOfTypeAll <PlatformLeaderboardsModel>().First().AddScore(difficultyBeatmap, levelCompletionResults.unmodifiedScore, gameplayModifiers);
            }
        }
Beispiel #19
0
        static bool Prefix(Action beforeSceneSwitchCallback, CampaignFlowCoordinator __instance, MissionSelectionNavigationController ____missionSelectionNavigationController, MenuTransitionsHelper ____menuTransitionsHelper, PlayerDataModelSO ____playerDataModel)
        {
            if (____missionSelectionNavigationController.selectedMissionNode.missionData is CustomMissionDataSO)
            {
                CustomMissionDataSO missionData = ____missionSelectionNavigationController.selectedMissionNode.missionData as CustomMissionDataSO;

                IDifficultyBeatmap          difficultyBeatmap           = BeatmapLevelDataExtensions.GetDifficultyBeatmap(Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded(missionData.customLevel.levelID).beatmapLevelData, missionData.beatmapCharacteristic, missionData.beatmapDifficulty);
                GameplayModifiers           gameplayModifiers           = missionData.gameplayModifiers;
                MissionObjective[]          missionObjectives           = missionData.missionObjectives;
                PlayerSpecificSettings      playerSpecificSettings      = ____playerDataModel.playerData.playerSpecificSettings;
                OverrideEnvironmentSettings overrideEnvironmentSettings = ____playerDataModel.playerData.overrideEnvironmentSettings;
                ColorSchemesSettings        colorSchemesSettings        = ____playerDataModel.playerData.colorSchemesSettings;
                ColorScheme overrideColorScheme = colorSchemesSettings.overrideDefaultColors ? colorSchemesSettings.GetSelectedColorScheme() : null;
                ____menuTransitionsHelper.StartMissionLevel(difficultyBeatmap, overrideEnvironmentSettings, overrideColorScheme, gameplayModifiers, missionObjectives, playerSpecificSettings, beforeSceneSwitchCallback, __instance.HandleMissionLevelSceneDidFinish);
                return(false);
            }
            return(true);
        }