// Yoinked from TournamentAssistant public static async void PlaySong(IPreviewBeatmapLevel level, BeatmapCharacteristicSO characteristic, BeatmapDifficulty difficulty, OverrideEnvironmentSettings overrideEnvironmentSettings = null, ColorScheme colorScheme = null, GameplayModifiers gameplayModifiers = null, PlayerSpecificSettings playerSettings = null, Action <StandardLevelScenesTransitionSetupDataSO, LevelCompletionResults> songFinishedCallback = null) { Action <IBeatmapLevel> SongLoaded = (loadedLevel) => { MenuTransitionsHelper _menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().First(); _menuSceneSetupData.StartStandardLevel( loadedLevel.beatmapLevelData.GetDifficultyBeatmap(characteristic, difficulty), overrideEnvironmentSettings, colorScheme, gameplayModifiers ?? new GameplayModifiers(), playerSettings ?? new PlayerSpecificSettings(), null, "Menu", false, null, (standardLevelScenesTransitionSetupData, results) => songFinishedCallback?.Invoke(standardLevelScenesTransitionSetupData, results) ); }; BeatmapLevelsModel beatmapLevelsModel = Resources.FindObjectsOfTypeAll <BeatmapLevelsModel>().FirstOrDefault(); var result = await GetLevelFromPreview(level); if (result != null && !(result?.isError == true)) { //HTTPstatus requires cover texture to be applied in here, and due to a fluke //of beat saber, it's not applied when the level is loaded, but it *is* //applied to the previewlevel it's loaded from var loadedLevel = result?.beatmapLevel; loadedLevel.SetField("_coverImageTexture2D", level.GetField <Texture2D>("_coverImageTexture2D")); SongLoaded(loadedLevel); } }
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; } }); }
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; } }); }
internal void Construct(SiraLog siraLog, UBinder <Plugin, PluginMetadata> pluginMetadata, ModListNavigationController navigationController, ModListViewController modListViewController, ModInfoViewController modInfoViewController, ModControlsViewController modControlsViewController, ModalPopupViewController modalPopupViewController, MenuTransitionsHelper menuTransitionsHelper) { this.siraLog = siraLog; modName = pluginMetadata.Value.Name; this.navigationController = navigationController; this.modListViewController = modListViewController; this.modInfoViewController = modInfoViewController; this.modControlsViewController = modControlsViewController; this.modalPopupViewController = modalPopupViewController; this.menuTransitionsHelper = menuTransitionsHelper; }
public static async void PlaySong(IPreviewBeatmapLevel level, BeatmapCharacteristicSO characteristic, BeatmapDifficulty difficulty, OverrideEnvironmentSettings overrideEnvironmentSettings = null, ColorScheme colorScheme = null, GameplayModifiers gameplayModifiers = null, PlayerSpecificSettings playerSettings = null, Action <StandardLevelScenesTransitionSetupDataSO, LevelCompletionResults> songFinishedCallback = null) { Action <IBeatmapLevel> SongLoaded = (loadedLevel) => { MenuTransitionsHelper _menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().First(); _menuSceneSetupData.StartStandardLevel( "Solo", loadedLevel.beatmapLevelData.GetDifficultyBeatmap(characteristic, difficulty), loadedLevel, overrideEnvironmentSettings, colorScheme, gameplayModifiers ?? new GameplayModifiers(), playerSettings ?? new PlayerSpecificSettings(), null, "Menu", false, null, (standardLevelScenesTransitionSetupData, results) => songFinishedCallback?.Invoke(standardLevelScenesTransitionSetupData, results) ); }; if ((level is PreviewBeatmapLevelSO && await HasDLCLevel(level.levelID)) || level is CustomPreviewBeatmapLevel) { Logger.Debug("Loading DLC/Custom level..."); var result = await GetLevelFromPreview(level); if (result != null && !(result?.isError == true)) { //HTTPstatus requires cover texture to be applied in here, and due to a fluke //of beat saber, it's not applied when the level is loaded, but it *is* //applied to the previewlevel it's loaded from var loadedLevel = result?.beatmapLevel; loadedLevel.SetField("_coverImage", level.GetField <Sprite>("_coverImage")); SongLoaded(loadedLevel); } } else if (level is BeatmapLevelSO) { Logger.Debug("Reading OST data without songloader..."); SongLoaded(level as IBeatmapLevel); } else { Logger.Debug($"Skipping unowned DLC ({level.songName})"); } }
private void PlaySong(Song song) { MenuTransitionsHelper menuTransitionHelper = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().FirstOrDefault(); var playerSettings = _playerDataModel.playerData.playerSpecificSettings; //Override defaults if we have forced options enabled if (song.PlayerOptions != PlayerOptions.None) { playerSettings = new PlayerSpecificSettings(); playerSettings.leftHanded = song.PlayerOptions.HasFlag(PlayerOptions.Mirror); playerSettings.staticLights = song.PlayerOptions.HasFlag(PlayerOptions.StaticLights); playerSettings.noTextsAndHuds = song.PlayerOptions.HasFlag(PlayerOptions.NoHud); playerSettings.advancedHud = song.PlayerOptions.HasFlag(PlayerOptions.AdvancedHud); playerSettings.reduceDebris = song.PlayerOptions.HasFlag(PlayerOptions.ReduceDebris); } GameplayModifiers gameplayModifiers = new GameplayModifiers(); gameplayModifiers.noFail = song.GameOptions.HasFlag(GameOptions.NoFail); gameplayModifiers.noBombs = song.GameOptions.HasFlag(GameOptions.NoBombs); gameplayModifiers.noObstacles = song.GameOptions.HasFlag(GameOptions.NoObstacles); if (song.GameOptions.HasFlag(GameOptions.SlowSong)) { gameplayModifiers.songSpeed = GameplayModifiers.SongSpeed.Slower; } else if (song.GameOptions.HasFlag(GameOptions.FastSong)) { gameplayModifiers.songSpeed = GameplayModifiers.SongSpeed.Faster; } gameplayModifiers.instaFail = song.GameOptions.HasFlag(GameOptions.InstaFail); gameplayModifiers.failOnSaberClash = song.GameOptions.HasFlag(GameOptions.FailOnClash); gameplayModifiers.batteryEnergy = song.GameOptions.HasFlag(GameOptions.BatteryEnergy); gameplayModifiers.fastNotes = song.GameOptions.HasFlag(GameOptions.FastNotes); gameplayModifiers.disappearingArrows = song.GameOptions.HasFlag(GameOptions.DisappearingArrows); gameplayModifiers.ghostNotes = song.GameOptions.HasFlag(GameOptions.GhostNotes); var colorSchemeSettings = _playerDataModel.playerData.colorSchemesSettings; SongUtils.PlaySong(song.PreviewBeatmap, song.Beatmap.parentDifficultyBeatmapSet.beatmapCharacteristic, song.Beatmap.difficulty, _playerDataModel.playerData.overrideEnvironmentSettings, colorSchemeSettings.GetColorSchemeForId(colorSchemeSettings.selectedColorSchemeId), gameplayModifiers, playerSettings, SongFinished); }
protected void Construct(Config config, SiraLog siraLog, DisoInfoView disoInfoView, DisoAudioView disoAudioView, MainFlowCoordinator mainFlowCoordinator, FadeInOutController fadeInOutController, MenuTransitionsHelper menuTransitionsHelper, HighwayTutorialSystem highwayTutorialSystem, DisoClickView disoClickView, DisoMusicView disoMusicView) { _config = config; _siraLog = siraLog; _disoInfoView = disoInfoView; _disoAudioView = disoAudioView; _mainFlowCoordinator = mainFlowCoordinator; _fadeInOutController = fadeInOutController; _menuTransitionHelper = menuTransitionsHelper; _highwayTutorialSystem = highwayTutorialSystem; _disoClickView = disoClickView; _disoMusicView = disoMusicView; _musicDir.Create(); _introDir.Create(); _outroDir.Create(); _clicksDir.Create(); _resultsDir.Create(); }
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); }
/// <summary> /// Play a loaded song /// </summary> /// <param name="p_Level">Loaded level</param> /// <param name="p_Characteristic">Beatmap game mode</param> /// <param name="p_Difficulty">Beatmap difficulty</param> /// <param name="p_OverrideEnvironmentSettings">Environment settings</param> /// <param name="p_ColorScheme">Color scheme</param> /// <param name="p_GameplayModifiers">Modifiers</param> /// <param name="p_PlayerSettings">Player settings</param> /// <param name="p_SongFinishedCallback">Callback when the song is finished</param> public static async void PlaySong(IPreviewBeatmapLevel p_Level, BeatmapCharacteristicSO p_Characteristic, BeatmapDifficulty p_Difficulty, OverrideEnvironmentSettings p_OverrideEnvironmentSettings = null, ColorScheme p_ColorScheme = null, GameplayModifiers p_GameplayModifiers = null, PlayerSpecificSettings p_PlayerSettings = null, Action <StandardLevelScenesTransitionSetupDataSO, LevelCompletionResults, IDifficultyBeatmap> p_SongFinishedCallback = null) { /* * Code from https://github.com/MatrikMoon/TournamentAssistant * * MIT License * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ Action <IBeatmapLevel> l_SongLoaded = (p_LoadedLevel) => { MenuTransitionsHelper l_MenuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().First(); var l_DifficultyBeatmap = p_LoadedLevel.beatmapLevelData.GetDifficultyBeatmap(p_Characteristic, p_Difficulty); l_MenuSceneSetupData.StartStandardLevel( p_Characteristic.name, l_DifficultyBeatmap, p_OverrideEnvironmentSettings, p_ColorScheme, p_GameplayModifiers ?? new GameplayModifiers(), p_PlayerSettings ?? new PlayerSpecificSettings(), null, "Menu", false, null, (p_StandardLevelScenesTransitionSetupData, p_Results) => p_SongFinishedCallback?.Invoke(p_StandardLevelScenesTransitionSetupData, p_Results, l_DifficultyBeatmap) ); }; if ((p_Level is PreviewBeatmapLevelSO && await HasDLCLevel(p_Level.levelID)) || p_Level is CustomPreviewBeatmapLevel) { Logger.Instance?.Debug("[SDK.Game][Level.PlaySong] Loading DLC/Custom level..."); var l_Result = await GetLevelFromPreview(p_Level); if (l_Result != null && !(l_Result?.isError == true)) { /// HTTPstatus requires cover texture to be applied in here, and due to a fluke var l_LoadedLevel = l_Result?.beatmapLevel; //l_LoadedLevel.SetField("_coverImageTexture2D", p_Level.GetField<Texture2D>("_coverImageTexture2D")); l_SongLoaded(l_LoadedLevel); } } else if (p_Level is BeatmapLevelSO) { Logger.Instance?.Debug("[SDK.Game][Level.PlaySong] Reading OST data without songloader..."); l_SongLoaded(p_Level as IBeatmapLevel); } else { Logger.Instance?.Debug($"[SDK.Game][Level.PlaySong] Skipping unowned DLC ({p_Level.songName})"); } }
public static async void PlaySong(IPreviewBeatmapLevel level, BeatmapCharacteristicSO characteristic, BeatmapDifficulty difficulty, PlaySong packet) { flow = (SoloFreePlayFlowCoordinator)Resources.FindObjectsOfTypeAll <MainFlowCoordinator>().First().GetField("_soloFreePlayFlowCoordinator"); Action <IBeatmapLevel> SongLoaded = (loadedLevel) => { Logger.Debug("G"); MenuTransitionsHelper _menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuTransitionsHelper>().First(); IDifficultyBeatmap diffbeatmap = loadedLevel.beatmapLevelData.GetDifficultyBeatmap(characteristic, difficulty); Logger.Debug("L"); GameplaySetupViewController gameplaySetupViewController = (GameplaySetupViewController)typeof(SinglePlayerLevelSelectionFlowCoordinator).GetField("_gameplaySetupViewController", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(flow); Logger.Debug("D"); OverrideEnvironmentSettings environmentSettings = gameplaySetupViewController.environmentOverrideSettings; ColorScheme scheme = gameplaySetupViewController.colorSchemesSettings.GetSelectedColorScheme(); //GameplayModifiers modifiers = gameplaySetupViewController.gameplayModifiers; PlayerSpecificSettings settings = gameplaySetupViewController.playerSettings; //TODO: re add modifier customizability PracticeSettings practiceSettings = ConvertPractice(packet.practiceSettings); GameplayModifiers modifiers = ConvertModifiers(packet.gameplayModifiers, gameplaySetupViewController.gameplayModifiers); Logger.Debug(diffbeatmap.level.levelID + " " + scheme.colorSchemeId); _menuSceneSetupData.StartStandardLevel( "Solo", diffbeatmap, diffbeatmap.level, environmentSettings, scheme, modifiers, settings, practiceSettings, "Menu", false, null, new Action <StandardLevelScenesTransitionSetupDataSO, LevelCompletionResults>((StandardLevelScenesTransitionSetupDataSO q, LevelCompletionResults r) => { }) ); }; if (flow == null || flow.gameObject == null || !flow.gameObject.activeInHierarchy) { Button button = Resources.FindObjectsOfTypeAll <Button>().Where(x => x != null && x.name == "SoloButton").First(); button.onClick.Invoke(); } if ((level is PreviewBeatmapLevelSO && await HasDLCLevel(level.levelID)) || level is CustomPreviewBeatmapLevel) { Logger.Debug("Loading DLC/Custom level..."); var result = await GetLevelFromPreview(level); if (!(result?.isError == true)) { SongLoaded(result?.beatmapLevel); return; } Logger.Debug("You Suck Idiot"); } else if (level is BeatmapLevelSO) { Logger.Debug("Reading OST data without songloader..."); SongLoaded(level as IBeatmapLevel); } else { Logger.Debug($"Skipping unowned DLC ({level.songName})"); } }