private static void UploadScore(IDifficultyBeatmap levelDifficulty, LevelCompletionResults results, out bool newHighScore) { var freePlayCoordinator = Resources.FindObjectsOfTypeAll <SoloFreePlayFlowCoordinator>().First(); var dataModel = freePlayCoordinator.GetPrivateField <PlayerDataModel>("_playerDataModel"); PlayerData currentLocalPlayer = dataModel.playerData; PlayerLevelStatsData playerLevelStatsData = currentLocalPlayer.GetPlayerLevelStatsData(levelDifficulty.level.levelID, levelDifficulty.difficulty, levelDifficulty.parentDifficultyBeatmapSet.beatmapCharacteristic); int prevHighScore = playerLevelStatsData.highScore; LevelCompletionResults levelCompletionResults = results; playerLevelStatsData.UpdateScoreData(levelCompletionResults.modifiedScore, levelCompletionResults.maxCombo, levelCompletionResults.fullCombo, levelCompletionResults.rank); newHighScore = playerLevelStatsData.highScore > prevHighScore; var platFormLeaderBoardsModel = freePlayCoordinator.GetPrivateField <PlatformLeaderboardsModel>("_platformLeaderboardsModel"); platFormLeaderBoardsModel.UploadScore( levelDifficulty, results.rawScore, results.modifiedScore, results.fullCombo, results.goodCutsCount, results.badCutsCount, results.missedCount, results.maxCombo, results.energy, results.gameplayModifiers); }
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 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!"); } }
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 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); } }