예제 #1
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);
                }
            }
        }
예제 #2
0
        private void SetPPText(bool canUsePositiveModifiers)
        {
            float ppValue = canUsePositiveModifiers ? PPUtils.CalculatePP(_rawPP, BeatSaberUtils.GetModifiedAcc(_accuracy, _modifiersModel, _modifiers))
                            : PPUtils.CalculatePP(_rawPP, BeatSaberUtils.GetModifiedAcc(_accuracy, _modifiersModel, BeatSaberUtils.RemovePositiveModifiers(_modifiers)));
            string ppText     = Math.Round(ppValue, 2).ToString("0.00");
            var    ppGain     = Math.Round(PPUtils.GetPPGain(ppValue, _id), 2);
            string ppGainText = ppGain.ToString("0.00");
            var    color      = ppGain > 0 ? "green" : "red";

            _ppText.SetText($"{ppText} (<color=\"{color}\">+{ppGain}</color>)");
        }