private void SwitchToNextMap() { if (nextSong == null || nextBeatmap == null || nextMapDiffInfo == null) { return; } if (BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData.playerSpecificSettings.environmentEffectsFilterDefaultPreset == EnvironmentEffectsFilterPreset.NoEffects) { nextBeatmap.SetField <BeatmapData, List <BeatmapEventData> >("_beatmapEventsData", new BeatmapEventData[0].ToList()); } AudioClip oldClip = GameObjects.songAudio.clip; TwitchPowers.ResetTimeSync(nextSong, 0f, nextSongInfo.songTimeOffset, 1f); TwitchPowers.ManuallySetNJSOffset(GameObjects.spawnController, nextMapDiffInfo.noteJumpMovementSpeed, nextMapDiffInfo.noteJumpStartBeatOffset, nextSongInfo.beatsPerMinute); // TwitchPowers.ClearCallbackItemDataList(callBackDataList); // DestroyNotes(); TwitchPowers.DestroyObjectsRaw(); TwitchPowers.ResetNoteCutSoundEffects(seManager); callbackController.SetField("_spawningStartTime", 0f); callbackController.SetNewBeatmapData(nextBeatmap); UpdatePauseMenu(); ClearSoundEffects(); //Destroying audio clip is actually bad idea // IPA.Utilities.Async.UnityMainThreadTaskScheduler.Factory.StartNew(() => { oldClip.UnloadAudioData(); AudioClip.Destroy(oldClip); }); Task.Run(PrepareNextSong); CheckIntroSkip(); ResetProgressUI(); }
public static IEnumerator MadScience(float length) { yield return(new WaitForSeconds(0f)); BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First(); BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData"); Plugin.Log("Grabbed BeatmapData"); List <BeatmapObjectData> objects; float start = Plugin.songAudio.time + 2; float end = start + length + 2f; foreach (BeatmapLineData line in beatmapData.beatmapLinesData) { objects = line.beatmapObjectsData.ToList(); for (int i = 0; i < objects.Count; ++i) { BeatmapObjectData beatmapObject = objects[i]; if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note) { objects.Add(NoteToWall(beatmapObject, Plugin.levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.beatsPerMinute)); } } objects = objects.OrderBy(o => o.time).ToList(); line.beatmapObjectsData = objects.ToArray(); objects.Clear(); } yield return(new WaitForSeconds(length + 2f)); callbackController.SetField("_beatmapData", beatmapData); }
private async void ReloadBeatmap() { string filePath = Path.Combine(_currentLevel.customLevelPath, _currentDiffBeatmap.beatmapFilename); string leveljson = File.ReadAllText(filePath); //Load new beatmapdata asynchronously BeatmapData newBeatmap = await _levelLoader.LoadBeatmapDataAsync(_currentLevel.customLevelPath, _currentDiffBeatmap.beatmapFilename, _currentLevel.standardLevelInfoSaveData, _cancelSource.Token); GameplayCoreSceneSetupData gameSetup = BS_Utils.Plugin.LevelData.GameplayCoreSceneSetupData; EnvironmentEffectsFilterPreset environmentEffectsFilterPreset = ((BeatmapDifficulty)(Enum.Parse(typeof(BeatmapDifficulty), _currentDiffBeatmap.difficulty)) == BeatmapDifficulty.ExpertPlus) ? gameSetup.playerSpecificSettings.environmentEffectsFilterExpertPlusPreset : gameSetup.playerSpecificSettings.environmentEffectsFilterDefaultPreset; newBeatmap = (BeatmapData)BeatmapDataTransformHelper.CreateTransformedBeatmapData(newBeatmap, _currentLevel, gameSetup.gameplayModifiers, gameSetup.practiceSettings, gameSetup.playerSpecificSettings.leftHanded, environmentEffectsFilterPreset, gameSetup.environmentInfo.environmentIntensityReductionOptions); //Hotswap Beatmap ResetTimeSync(); DestroyObjects(); ResetNoteCutSoundEffects(); _callbackController.SetField("_spawningStartTime", _songStartTime); _callbackController.SetNewBeatmapData(newBeatmap); //Unpause if (_pauseController.GetField <bool>("_paused")) { CheckPracticePlugin(); _pauseController.HandlePauseMenuManagerDidPressContinueButton(); } _queuedLoad = false; }
public static IEnumerator RandomBombs(float length) { var text = GameObject.Find("Chat Powers").GetComponent <GamePlayModifiersPlus.TwitchStuff.GMPDisplay>().activeCommandText; text.text += " Bombs | "; yield return(new WaitForSeconds(0f)); BeatmapObjectCallbackController callbackController = Resources.FindObjectsOfTypeAll <BeatmapObjectCallbackController>().First(); BeatmapData beatmapData = callbackController.GetField <BeatmapData>("_beatmapData"); Plugin.Log("Grabbed BeatmapData"); BeatmapObjectData[] objects; NoteData note; float start = Plugin.songAudio.time + 2; float end = start + length + 2f; foreach (BeatmapLineData line in beatmapData.beatmapLinesData) { objects = line.beatmapObjectsData; foreach (BeatmapObjectData beatmapObject in objects) { if (beatmapObject.beatmapObjectType == BeatmapObjectType.Note) { if (beatmapObject.time > start && beatmapObject.time < end) { try { // Plugin.Log("Attempting to Convert to Bomb"); note = beatmapObject as NoteData; int randMax = (int)((1 / ChatConfig.bombsChance) * 100); int randMin = 100; int random = Random.Range(1, randMax); // Plugin.Log("Min: " + randMin + " Max: " + randMax + " Number: " + random); if (random <= randMin || ChatConfig.bombsChance == 1) { note.SetProperty("noteType", NoteType.Bomb); } } catch (System.Exception ex) { Plugin.Log(ex.ToString()); } } } } } yield return(new WaitForSeconds(length + 2f)); text.text = text.text.Replace(" Bombs | ", ""); callbackController.SetField("_beatmapData", beatmapData); }