Example #1
0
 static void Postfix(ref LevelCompletionResults __result, LevelCompletionResults.LevelEndStateType levelEndStateType)
 {
     if ((ScoreSubmission.WasDisabled || ScoreSubmission.disabled || ScoreSubmission.prolongedDisable) && levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared)
     {
         Plugin.scenesTransitionSetupData.Get <GameplayCoreSceneSetupData>().SetField("practiceSettings", new PracticeSettings());
         Plugin.scenesTransitionSetupData = null;
         __result.SetField("rawScore", -__result.rawScore);
     }
 }
Example #2
0
            public override LevelCompletionResults FillLevelCompletionResults(LevelCompletionResults.LevelEndStateType levelEndStateType, LevelCompletionResults.LevelEndAction levelEndAction)
            {
                var results = base.FillLevelCompletionResults(levelEndStateType, levelEndAction);

                if (levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared)
                {
                    if (_submission._tickets.Count() > 0)
                    {
                        _gameplayCoreSceneSetupData.SetField <GameplayCoreSceneSetupData, PracticeSettings>("practiceSettings", new SiraPracticeSettings(_gameplayCoreSceneSetupData.practiceSettings));
                        results.SetField("rawScore", -results.rawScore);
                    }
                }
                return(results);
            }
Example #3
0
        static void Postfix(ref LevelCompletionResults __result, LevelCompletionResults.LevelEndStateType levelEndStateType)
        {
            if ((ScoreSubmission.WasDisabled || ScoreSubmission.disabled || ScoreSubmission.prolongedDisable) && levelEndStateType == LevelCompletionResults.LevelEndStateType.Cleared && Plugin.scenesTransitionSetupData != null)
            {
                var gameplayCoreSceneSetupData = GameplayCoreSceneSetupDataAccessor(ref Plugin.scenesTransitionSetupData).OfType <GameplayCoreSceneSetupData>().FirstOrDefault();
                if (gameplayCoreSceneSetupData != null)
                {
                    PracticeSettingsAccessor(ref gameplayCoreSceneSetupData) = new PracticeSettings();
                }

                Plugin.scenesTransitionSetupData = null;
                __result.SetField("multipliedScore", -__result.multipliedScore);
            }
        }
Example #4
0
        public void SubmitActivity(LevelCompletionResults levelCompletionResults)
        {
            try
            {
                LevelCompletionResults.LevelEndStateType levelEndState = levelCompletionResults.levelEndStateType;
                var currentMap  = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData;
                var currentSong = currentMap.difficultyBeatmap.level;

                if (currentSong.IsWip())
                {
                    Logger.log.Debug("WIP so not sending activity.");
                    return;
                }

                var scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault();
                var modifiedScore   = ScoreModel.GetModifiedScoreForGameplayModifiersScoreMultiplier(levelCompletionResults.rawScore, scoreController.gameplayModifiersScoreMultiplier);
                var maxScore        = scoreController.immediateMaxPossibleRawScore;
                var acc             = modifiedScore / (maxScore * scoreController.gameplayModifiersScoreMultiplier);
                var normalizedAcc   = (acc * 100.0f);


                var customLevel = true;

                if (!(currentSong is CustomBeatmapLevel))
                {
                    customLevel = false; // OST Level
                    Logger.log.Debug("OST Level");
                }

                var activity = new Activity
                {
                    NoFail          = currentMap.gameplayModifiers.noFailOn0Energy || currentMap.gameplayModifiers.demoNoFail,
                    WipMap          = currentSong.levelID.EndsWith("WIP"),
                    PracticeMode    = currentMap.practiceSettings != null,
                    Difficulty      = currentMap.difficultyBeatmap.difficulty,
                    EndType         = levelEndState,
                    SongName        = currentSong.songName,
                    SongSubName     = currentSong.songSubName,
                    SongAuthorName  = currentSong.songAuthorName,
                    LevelAuthorName = currentSong.levelAuthorName,
                    FullCombo       = levelCompletionResults.fullCombo,
                    EndSongTime     = levelCompletionResults.endSongTime.ToString("##.##"),
                    SongDuration    = levelCompletionResults.songDuration.ToString("##.##"),
                    Accuracy        = normalizedAcc.ToString("##.##"),
                    Is90            = currentMap.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName.Equals("90Degree")
                };

                // cant be 90 and 360 at the same time, so if weve already detected 90, cant be 360, this is a best guess effort
                activity.Is360    = (currentMap.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName.Equals("360Degree") || currentMap.difficultyBeatmap.beatmapData.spawnRotationEventsCount > 0) && !activity.Is90;
                activity.OneSaber = currentMap.difficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic.serializedName.Equals("OneSaber");

                if (customLevel)
                {
                    activity.Hash =
                        SongCore.Utilities.Hashing.GetCustomLevelHash(currentSong as CustomPreviewBeatmapLevel);
                }
                else
                {
                    activity.Hash = currentSong.levelID;
                    activity.Ost  = true;
                }


                string json = JsonConvert.SerializeObject(activity);

                SharedCoroutineStarter.instance.StartCoroutine(_requestService.Post("activity/", json));
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex);
            }
        }
        public void SubmitActivity(LevelCompletionResults levelCompletionResults)
        {
            try
            {
                LevelCompletionResults.LevelEndStateType levelEndState = levelCompletionResults.levelEndStateType;
                var currentMap  = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData;
                var currentSong = currentMap.difficultyBeatmap.level;

                if (currentSong.IsWip())
                {
                    Logger.log.Debug("WIP so not sending activity.");
                    return;
                }

                // Calculations for acc
                var modifiedScore = levelCompletionResults.gameplayModifiersModel.GetModifiedScoreForGameplayModifiers(levelCompletionResults.rawScore, levelCompletionResults.gameplayModifiers);
                var maxScore      = ScoreModel.MaxRawScoreForNumberOfNotes(currentMap.difficultyBeatmap.beatmapData.notesCount);
                var multiplier    = levelCompletionResults.gameplayModifiersModel.GetTotalMultiplier(levelCompletionResults.gameplayModifiers);
                var acc           = modifiedScore / (maxScore * multiplier);
                var normalizedAcc = (acc * 100.0f);


                var customLevel = true;

                if (!(currentSong is CustomBeatmapLevel))
                {
                    customLevel = false; // OST Level
                    Logger.log.Debug("OST Level");
                }

                var activity = new Activity
                {
                    NoFail          = currentMap.gameplayModifiers.noFail,
                    WipMap          = currentSong.levelID.EndsWith("WIP"),
                    PracticeMode    = currentMap.practiceSettings != null,
                    Difficulty      = currentMap.difficultyBeatmap.difficulty,
                    EndType         = levelEndState,
                    SongName        = currentSong.songName,
                    SongSubName     = currentSong.songSubName,
                    SongAuthorName  = currentSong.songAuthorName,
                    LevelAuthorName = currentSong.levelAuthorName,
                    FullCombo       = levelCompletionResults.fullCombo,
                    EndSongTime     = levelCompletionResults.endSongTime.ToString("##.##"),
                    SongDuration    = levelCompletionResults.songDuration.ToString("##.##"),
                    Accuracy        = normalizedAcc.ToString("##.##"),
                    Is90            = BS_Utils.Gameplay.Gamemode.GameMode.Equals("90Degree")
                };
                // cant be 90 and 360 at the same time, so if weve already detected 90, cant be 360, this is a best guess effort
                activity.Is360    = (BS_Utils.Gameplay.Gamemode.GameMode.Equals("360Degree") || currentMap.difficultyBeatmap.beatmapData.spawnRotationEventsCount > 0) && !activity.Is90;
                activity.OneSaber = BS_Utils.Gameplay.Gamemode.GameMode.Equals("OneSaber");

                if (customLevel)
                {
                    activity.Hash =
                        SongCore.Utilities.Hashing.GetCustomLevelHash(currentSong as CustomPreviewBeatmapLevel);
                }
                else
                {
                    activity.Hash = currentSong.levelID;
                    activity.Ost  = true;
                }


                string json = JsonConvert.SerializeObject(activity);

                SharedCoroutineStarter.instance.StartCoroutine(PostRequest(_apiUrl + "activity/", json));
            }
            catch (Exception ex)
            {
                Logger.log.Error(ex);
            }
        }