Example #1
0
        // Purposefully ignore modifiers here - only 2 maps have them enabled and it doesn't make much sense to just filter to those two
        private static float GetHighestPP(IPreviewBeatmapLevel previewBeatmapLevel, bool ppGain)
        {
            float maxPP = 0;
            var   id    = SongDataUtils.GetHash(previewBeatmapLevel.levelID);

            // Check if in SDC
            if (SongDataCore.Plugin.Songs.Data.Songs.ContainsKey(id))
            {
                // Loop through each diff
                foreach (var diff in SongDataCore.Plugin.Songs.Data.Songs[id].diffs)
                {
                    var difficulty = SongDataUtils.GetBeatmapDifficulty(diff.diff);
                    var songID     = new SongID(id, difficulty);
                    // Only go through ranked songs
                    if (SongDataUtils.IsRankedSong(songID))
                    {
                        float pp = PPUtils.CalculatePP(songID, AccLoader.instance.GetAcc(songID));
                        if (ppGain)
                        {
                            pp = PPUtils.GetPPGain(pp, songID);
                        }
                        maxPP = pp > maxPP ? pp : maxPP;
                    }
                }
                return(maxPP);
            }
            return(0);
        }
Example #2
0
        IEnumerator FindDifficultyBeatmap()
        {
            yield return(new WaitUntil(() => BS_Utils.Plugin.LevelData.IsSet));

            _difficultyBeatmap = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.difficultyBeatmap;
            _songID            = new SongID(SongDataUtils.GetHash(_difficultyBeatmap.level.levelID), _difficultyBeatmap.difficulty);
            _rawPP             = SongDataUtils.GetRawPP(_songID);

            // modifiers
            var gameplayModifiersModelSO = Resources.FindObjectsOfTypeAll <GameplayModifiersModelSO>().FirstOrDefault();
            var gameplayModifiers        = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.gameplayModifiers;

            _multiplier = gameplayModifiersModelSO.GetTotalMultiplier(gameplayModifiers);
            _multiplier = (Config.ignoreNoFail && gameplayModifiers.noFail) ? _multiplier + 0.5 : _multiplier;

            // Only update for ranked songs
            if (SongDataUtils.IsRankedSong(_songID))
            {
                yield return(new WaitUntil(() => _beatmapObjectManager != null));

                _beatmapObjectManager.noteWasCutEvent    += OnNoteCut;
                _beatmapObjectManager.noteWasMissedEvent += OnNoteMissed;

                yield return(new WaitUntil(() => _scoreController != null));

                _scoreController.scoreDidChangeEvent += OnScoreChange;
                if (!Config.hideOnStart)
                {
                    UpdateCounter();
                }
            }
        }
Example #3
0
        public void ModifiersChanged()
        {
            var gameplayModifiersPanelController = Resources.FindObjectsOfTypeAll <GameplayModifiersPanelController>().FirstOrDefault();

            _modifiers = gameplayModifiersPanelController.GetPrivateField <GameplayModifiers>("_gameplayModifiers");
            if (SongDataUtils.IsRankedSong(_id))
            {
                SetPPText(PPUtils.AllowedModifiers(_id.id, _modifiers));
            }
        }
Example #4
0
        public void LevelCleared(StandardLevelScenesTransitionSetupDataSO standardLevelScenesTransitionSetupDataSO, LevelCompletionResults levelCompletionResults)
        {
            Logger.log.Debug("Level cleared");
            // Score submission disabled or using practice mode
            if (BS_Utils.Gameplay.ScoreSubmission.WasDisabled || BS_Utils.Gameplay.ScoreSubmission.ProlongedDisabled ||
                ((GameplayCoreSceneSetupData)standardLevelScenesTransitionSetupDataSO.sceneSetupDataArray.First(x => x.GetType().Equals(typeof(GameplayCoreSceneSetupData)))).practiceSettings != null)
            {
                Logger.log.Debug("Practice mode or score disabled");
                return;
            }

            var gameplayCoreSceneSetupData = ((GameplayCoreSceneSetupData)standardLevelScenesTransitionSetupDataSO.sceneSetupDataArray[1]);
            var difficultyBeatmap          = gameplayCoreSceneSetupData.difficultyBeatmap;

            SongID songID = SongDataUtils.GetSongID(difficultyBeatmap);

            // I don't like putting play history here but until I do a refactor I'm gonna keep it here
            if (SongDataUtils.IsRankedSong(songID) || Config.playHistory)
            {
                Logger.log.Debug("Beat song");
                GameplayModifiers modifiers = new GameplayModifiers(levelCompletionResults.gameplayModifiers);
                // Remove positive modifiers if not allowed
                if (!PPUtils.AllowedModifiers(songID.id, modifiers))
                {
                    Logger.log.Debug("Using invalid modifiers, removing from score");
                    modifiers = BeatSaberUtils.RemovePositiveModifiers(modifiers);
                }

                var    multiplier = levelCompletionResults.gameplayModifiersModel.GetTotalMultiplier(modifiers);
                var    score      = levelCompletionResults.rawScore * multiplier;
                var    maxScore   = ScoreModel.MaxRawScoreForNumberOfNotes(difficultyBeatmap.beatmapData.notesCount);
                double acc        = (double)score / (double)maxScore;
                Logger.log.Debug($"acc: {acc}");

                if (SongDataUtils.IsRankedSong(songID))
                {
                    SubmitPlay(songID, acc);
                }
                else
                {
                    PlayHistoryTracker.UpdatePlayHistory(songID, acc);
                }
            }
        }
Example #5
0
        internal void Refresh(string id)
        {
            if (!Config.showInfo)
            {
                _parentObject.SetActive(false);
                return;
            }

            try
            {
                IDifficultyBeatmap difficultyBeatmap = _standardLevelDetailView.selectedDifficultyBeatmap;
                var newId = new ProfileDataLoader.SongID(id, difficultyBeatmap.difficulty);

                if (SongDataUtils.IsRankedSong(newId))
                {
                    _parentObject.SetActive(true);
                    _rawPP = SongDataUtils.GetRawPP(newId);
                    // Only load the acc in when a new song is selected
                    if (_id == null || !newId.Equals(_id))
                    {
                        _id = newId;
                        LoadAcc();
                    }

                    SetPPText(PPUtils.AllowedModifiers(_id.id, _modifiers));
                }
                else
                {
                    _parentObject.SetActive(false);
                }
            }
            catch (Exception)
            {
                Logger.log.Debug($"error with difficulty for song {id}");
                _parentObject.SetActive(false);
            }
        }