Exemplo n.º 1
0
        private static void StartLevel(IBeatmapLevel beatmapLevel, SongInfo songInfo)
        {
            MenuTransitionsHelper menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().FirstOrDefault();
            PlayerData            playerSettings     = Resources.FindObjectsOfTypeAll <PlayerDataModel>().First().playerData;

            playerSettings.playerSpecificSettings.leftHanded = songInfo.leftHanded;
            playerSettings.practiceSettings.songSpeedMul     = 1.0f;
            songInfo.modifiers.noFail = true;
            IBeatmapLevel level = beatmapLevel;

            PreviewDifficultyBeatmapSet[] sets            = songInfo.beatmap.previewDifficultyBeatmapSets;
            BeatmapCharacteristicSO       characteristics = null;

            foreach (PreviewDifficultyBeatmapSet set in sets)
            {
                if (("Mode" + set.beatmapCharacteristic.compoundIdPartName) == Convert.ToString(songInfo.mode))
                {
                    characteristics = set.beatmapCharacteristic;
                }
            }
            //BeatmapCharacteristicSO characteristics = songInfo.beatmap.previewDifficultyBeatmapSets[0].beatmapCharacteristic;
            IDifficultyBeatmap levelDifficulty = BeatmapLevelDataExtensions.GetDifficultyBeatmap(level.beatmapLevelData, characteristics, songInfo.difficulty);

            menuSceneSetupData.StartStandardLevel(levelDifficulty,
                                                  playerSettings.overrideEnvironmentSettings.overrideEnvironments ? playerSettings.overrideEnvironmentSettings : null,
                                                  playerSettings.colorSchemesSettings.overrideDefaultColors ? playerSettings.colorSchemesSettings.GetSelectedColorScheme() : null,
                                                  songInfo.modifiers,
                                                  playerSettings.playerSpecificSettings,
                                                  null, "Exit", false, () => { }, (StandardLevelScenesTransitionSetupDataSO sceneTransition, LevelCompletionResults results) =>
            {
                bool newHighScore = false;

                var mainFlowCoordinator = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();

                if (results.levelEndAction == LevelCompletionResults.LevelEndAction.Restart)
                {
                    return;
                }

                switch (results.levelEndStateType)
                {
                case LevelCompletionResults.LevelEndStateType.None:
                    break;

                case LevelCompletionResults.LevelEndStateType.Cleared:
                    Logger.log.Info("Showing menu");
                    break;

                case LevelCompletionResults.LevelEndStateType.Failed:
                    Logger.log.Info("Showing menu");
                    break;

                default:
                    break;
                }
            });
        }
Exemplo n.º 2
0
        private static void StartLevel(IBeatmapLevel beatmapLevel, CustomPreviewBeatmapLevel beatmap, BeatmapDifficulty difficulty)
        {
            Logger.log.Info("Starting level");

            MenuTransitionsHelper menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().FirstOrDefault();
            PlayerData            playerSettings     = Resources.FindObjectsOfTypeAll <PlayerDataModel>().FirstOrDefault().playerData;

            var gamePlayModifiers = new GameplayModifiers();

            gamePlayModifiers.IsWithoutModifiers();

            IBeatmapLevel           level           = beatmapLevel;
            BeatmapCharacteristicSO characteristics = beatmap.previewDifficultyBeatmapSets[0].beatmapCharacteristic;
            IDifficultyBeatmap      levelDifficulty = BeatmapLevelDataExtensions.GetDifficultyBeatmap(level.beatmapLevelData, characteristics, difficulty);

            menuSceneSetupData.StartStandardLevel(levelDifficulty,
                                                  playerSettings.overrideEnvironmentSettings.overrideEnvironments ? playerSettings.overrideEnvironmentSettings : null,
                                                  playerSettings.colorSchemesSettings.overrideDefaultColors ? playerSettings.colorSchemesSettings.GetSelectedColorScheme() : null,
                                                  gamePlayModifiers,
                                                  playerSettings.playerSpecificSettings,
                                                  playerSettings.practiceSettings, "Exit", false, () => { }, (StandardLevelScenesTransitionSetupDataSO sceneTransition, LevelCompletionResults results) =>
            {
                bool newHighScore = false;

                var mainFlowCoordinator       = Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First();
                RandomSongMenu randomSongMenu = BeatSaberUI.CreateFlowCoordinator <RandomSongMenu>();

                if (results.levelEndAction == LevelCompletionResults.LevelEndAction.Restart)
                {
                    Logger.log.Info("Restarting level");
                    return;
                }

                switch (results.levelEndStateType)
                {
                case LevelCompletionResults.LevelEndStateType.None:
                    break;

                case LevelCompletionResults.LevelEndStateType.Cleared:
                    UploadScore(levelDifficulty, results, out newHighScore);
                    randomSongMenu.Show(beatmap, difficulty, levelDifficulty, results, newHighScore);
                    Logger.log.Info("Showing menu");
                    break;

                case LevelCompletionResults.LevelEndStateType.Failed:
                    Logger.log.Info("Showing menu");
                    randomSongMenu.Show(beatmap, difficulty, levelDifficulty, results, newHighScore);
                    break;

                default:
                    break;
                }
            });
        }
Exemplo n.º 3
0
 static bool Prefix(MissionCompletionResults missionCompletionResults, MissionNode missionNode, AchievementsEvaluationHandler __instance)
 {
     if (missionNode.missionData is CustomMissionDataSO)
     {
         __instance.ProcessMissionFinishData(missionNode, missionCompletionResults);
         IDifficultyBeatmap difficultyBeatmap = BeatmapLevelDataExtensions.GetDifficultyBeatmap(Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded((missionNode.missionData as CustomMissionDataSO).customLevel.levelID).beatmapLevelData, missionNode.missionData.beatmapCharacteristic, missionNode.missionData.beatmapDifficulty);
         __instance.ProcessLevelFinishData(difficultyBeatmap, missionCompletionResults.levelCompletionResults);
         return(false);
     }
     return(true);
 }
        public void HandleMissionLevelDetailViewControllerDidPressPlayButtonPlay(MissionLevelDetailViewController viewController)
        {
            Challenge     challenge   = ((CustomMissionDataSO)viewController.missionNode.missionData).challenge;
            MissionDataSO missionData = viewController.missionNode.missionData;
            String        failedMods  = LoadExternalModifiers(challenge);
            List <GameplayModifierParamsSO> errorList = new List <GameplayModifierParamsSO>();

            if (failedMods.Length > 0)
            {
                foreach (string s in failedMods.Split(' '))
                {
                    errorList.Add(APITools.CreateModifierParam(Assets.ErrorIcon, "Error - External Mod", "Please install or update the following mod: " + s));
                }
            }
            if (viewController.missionNode.missionData.beatmapCharacteristic.descriptionLocalizationKey == "ERROR NOT FOUND")
            {
                errorList.Add(APITools.CreateModifierParam(Assets.ErrorIcon, "Error - Characteristic Not Found", "Could not find the characteristic \"" + challenge.characteristic + "\" for this map"));
            }
            else if (BeatmapLevelDataExtensions.GetDifficultyBeatmap(Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded((missionData as CustomMissionDataSO).customLevel.levelID).beatmapLevelData, missionData.beatmapCharacteristic, missionData.beatmapDifficulty) == null)
            {
                errorList.Add(APITools.CreateModifierParam(Assets.ErrorIcon, "Error - Difficulty Not Found", "Could not find the difficulty \"" + challenge.difficulty.ToString() + "\" for this map"));
            }
            else
            {
                DifficultyData difficultyData = Collections.RetrieveDifficultyData(BeatmapLevelDataExtensions.GetDifficultyBeatmap(Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded((missionData as CustomMissionDataSO).customLevel.levelID).beatmapLevelData, missionData.beatmapCharacteristic, missionData.beatmapDifficulty));
                foreach (string requirement in difficultyData.additionalDifficultyData._requirements)
                {
                    if (Collections.capabilities.Contains(requirement) || requirement.StartsWith("Complete Campaign Challenge - "))
                    {
                        continue;
                    }
                    errorList.Add(APITools.CreateModifierParam(Assets.ErrorIcon, "Error - Missing Level Requirement", "Could not find the capability to play levels with \"" + requirement + "\""));
                }
            }
            foreach (ChallengeRequirement requirement in challenge.requirements)
            {
                if (ChallengeRequirement.GetObjectiveName(requirement.type) == "ERROR")
                {
                    errorList.Add(APITools.CreateModifierParam(Assets.ErrorIcon, "Error - Mission Objective Not Found", "You likely have a typo in the requirement name"));
                }
            }
            if (errorList.Count == 0)
            {
                Gamemode.NextLevelIsIsolated("Custom Campaigns");
                _missionSelectionNavigationController.HandleMissionLevelDetailViewControllerDidPressPlayButton(viewController);
            }
            else
            {
                LoadModifiersPanel(errorList);
            }
        }
        static bool Prefix(Action beforeSceneSwitchCallback, CampaignFlowCoordinator __instance, MissionSelectionNavigationController ____missionSelectionNavigationController, MenuTransitionsHelper ____menuTransitionsHelper, PlayerDataModel ____playerDataModel)
        {
            if (____missionSelectionNavigationController.selectedMissionNode.missionData is CustomMissionDataSO)
            {
                CustomMissionDataSO missionData = ____missionSelectionNavigationController.selectedMissionNode.missionData as CustomMissionDataSO;

                IDifficultyBeatmap     difficultyBeatmap      = BeatmapLevelDataExtensions.GetDifficultyBeatmap(Loader.BeatmapLevelsModelSO.GetBeatmapLevelIfLoaded(missionData.customLevel.levelID).beatmapLevelData, missionData.beatmapCharacteristic, missionData.beatmapDifficulty);
                GameplayModifiers      gameplayModifiers      = missionData.gameplayModifiers;
                MissionObjective[]     missionObjectives      = missionData.missionObjectives;
                PlayerSpecificSettings playerSpecificSettings = ____playerDataModel.playerData.playerSpecificSettings;
                ColorSchemesSettings   colorSchemesSettings   = ____playerDataModel.playerData.colorSchemesSettings;
                ColorScheme            overrideColorScheme    = colorSchemesSettings.overrideDefaultColors ? colorSchemesSettings.GetSelectedColorScheme() : null;
                ____menuTransitionsHelper.StartMissionLevel("", difficultyBeatmap, overrideColorScheme, gameplayModifiers, missionObjectives, playerSpecificSettings, beforeSceneSwitchCallback, __instance.HandleMissionLevelSceneDidFinish);
                return(false);
            }
            return(true);
        }