static void Postfix(StandardLevelDetailViewController __instance, ref LevelParamsPanel ____levelParamsPanel, ref TextMeshProUGUI ____highScoreText, ref IDifficultyBeatmap ____selectedDifficultyBeatmap, ref IPlayer ____player) { try { IBeatmapLevel level = ____selectedDifficultyBeatmap.level; PlayerDataModelSO.LocalPlayer localPlayer = ____player as PlayerDataModelSO.LocalPlayer; if (localPlayer != null) { PlayerLevelStatsData playerLevelStats = localPlayer.GetPlayerLevelStatsData(level.levelID, ____selectedDifficultyBeatmap.difficulty, ____selectedDifficultyBeatmap.parentDifficultyBeatmapSet.beatmapCharacteristic); if (playerLevelStats != null) { if (playerLevelStats.validScore) { int highScore = int.Parse(____highScoreText.text); int maxScore = ScoreController.MaxRawScoreForNumberOfNotes(____selectedDifficultyBeatmap.beatmapData.notesCount); float percent = (float)highScore / maxScore; percent *= 100; ____highScoreText.overflowMode = TextOverflowModes.Overflow; ____highScoreText.enableWordWrapping = false; ____highScoreText.richText = true; ____highScoreText.text += "<size=75%> <#FFFFFF> (" + "<#FFD42A>" + percent.ToString("F2") + "%" + "<#FFFFFF>)"; } } } } catch (Exception ex) { Plugin.Log("Exception in DetailView Postfix: \n " + ex); } }
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); } }
public void SetNextRankText() { if (!poll) { return; } // At launch, the UI exists, but no level is selected. LevelSO.DifficultyBeatmap difficultyBeatMap = ReflectionUtil.GetPrivateField <LevelSO.DifficultyBeatmap>(_songDetailViewController, "_difficultyBeatmap"); if (difficultyBeatMap == null) { return; } // If the player hasn't finished a level, blank out the Next Rank text to fit in with the rest of the UI. if (_highScoreText.text == "-") { _nextRankText.text = _highScoreText.text; return; } BeatmapDifficulty difficulty = difficultyBeatMap.difficulty; int notesCount = difficultyBeatMap.beatmapData.notesCount; PlayerDataModelSO.LocalPlayer player = ReflectionUtil.GetPrivateField <PlayerDataModelSO.LocalPlayer>(_songDetailViewController, "_player"); PlayerLevelStatsData playerLevelStatsData = player.GetPlayerLevelStatsData(difficultyBeatMap.level.levelID, difficulty); _nextRankText.text = GetPointsToNextRank(notesCount, playerLevelStatsData.highScore); }
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!"); } }
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); } }