public static IEnumerator SpeedChange(float length, float pitch) { var text = GameObject.Find("Multi Powers").GetComponent <MultiGMPDisplay>().activeCommandText; text.text += " Speed | "; float beatAlignOffset = Plugin.soundEffectManager.GetField <float>("_beatAlignOffset"); GameplayCoreSceneSetup sceneSetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().First(); float songspeedmul = Plugin.levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; Plugin.songAudio.pitch = pitch; Plugin.currentSongSpeed = pitch; AudioManagerSO mixer = sceneSetup.GetField <AudioManagerSO>("_audioMixer"); mixer.musicPitch = 1f / pitch; // if (pitch != 1f) // Plugin.AudioTimeSync.forcedAudioSync = true; // else // Plugin.AudioTimeSync.forcedAudioSync = false; Plugin.soundEffectManager.SetField("_beatAlignOffset", beatAlignOffset * (1.5f * pitch)); yield return(new WaitForSeconds(length)); Plugin.songAudio.pitch = songspeedmul; Plugin.currentSongSpeed = songspeedmul; mixer.musicPitch = 1 / songspeedmul; if (songspeedmul == 1f) { mixer.musicPitch = 1; // Plugin.AudioTimeSync.forcedAudioSync = false; } Plugin.soundEffectManager.SetField("_beatAlignOffset", beatAlignOffset); text.text = text.text.Replace(" Speed | ", ""); }
public override void EnableModifier() { if (!_audioTimeSyncController) { _audioTimeSyncController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); } if (!_gameCoreSceneSetup) { _gameCoreSceneSetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().FirstOrDefault(); } if (!_mixer) { _mixer = _gameCoreSceneSetup.GetPrivateField <AudioManagerSO>("_audioMixer"); } _audioSource = _audioTimeSyncController.GetPrivateField <AudioSource>("_audioSource"); _baseTimeScale = _audioTimeSyncController.GetPrivateField <float>("_timeScale"); gameObject.Tween("TimeWarping" + gameObject.GetInstanceID(), _baseTimeScale, _baseTimeScale + Mathf.Clamp(0.2f * strength, 0, float.PositiveInfinity), 1f, TweenScaleFunctions.Linear, tween => { _audioTimeSyncController.SetPrivateField("_timeScale", tween.CurrentValue); _audioSource.pitch = tween.CurrentValue; _mixer.musicPitch = 1f / tween.CurrentValue; }); // RIP TimeController //gameObject.Tween("TimeWarping" + gameObject.GetInstanceID(), TimeController.Instance.ManipulatedTime, // Mathf.Clamp(1.25f * strength, 1, float.PositiveInfinity), 1f, TweenScaleFunctions.Linear, // tween => { // TimeController.Instance.ManipulatedTime = tween.CurrentValue; // }); }
public static IEnumerator FetchObjects() { yield return(new WaitForSeconds(0.1f)); soundEffectManager = Resources.FindObjectsOfTypeAll <NoteCutSoundEffectManager>().LastOrDefault(); beatmapObjectManager = Resources.FindObjectsOfTypeAll <BeatmapObjectExecutionRatingsRecorder>().LastOrDefault().GetPrivateField <BeatmapObjectManager>("_beatmapObjectManager") as BasicBeatmapObjectManager; spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().LastOrDefault(); energyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().LastOrDefault(); ColorManager = Resources.FindObjectsOfTypeAll <ColorManager>().LastOrDefault(); pauseManager = Resources.FindObjectsOfTypeAll <StandardLevelGameplayManager>().LastOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().LastOrDefault(); if (AudioTimeSync != null) { songAudio = AudioTimeSync.GetField <AudioSource>("_audioSource"); if (songAudio == null) { Plugin.Log("Audio null"); } } Mixer = soundEffectManager.GetField <AudioManagerSO>("_audioManager"); GameModifiersController.SetupSpawnCallbacks(); }
public void OnActiveSceneChanged(Scene oldScene, Scene newScene) { Object.Destroy(Resources.FindObjectsOfTypeAll <UIElementsCreator>().FirstOrDefault()?.gameObject); if (newScene.name == MenuSceneName) { resultsViewController = Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault(); if (resultsViewController != null) { resultsViewController.didActivateEvent -= ResultsViewController_didActivateEvent; resultsViewController.didActivateEvent += ResultsViewController_didActivateEvent; } } else if (newScene.name == GameSceneName) { if (_levelData == null) { _levelData = BS_Utils.Plugin.LevelData; if (_levelData == null) { return; } BS_Utils.Plugin.LevelDidFinishEvent += MainGameSceneSetupDataOnDidFinishEvent; } if (_spawnController == null) { _spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault(); } if (_lastLevelId != _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID && !string.IsNullOrEmpty(_lastLevelId)) { PlayingNewSong = true; // TimeScale = 1; _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; } else { PlayingNewSong = false; } _lastLevelId = _levelData.GameplayCoreSceneSetupData.difficultyBeatmap.level.levelID; _mixer = Resources.FindObjectsOfTypeAll <AudioManagerSO>().FirstOrDefault(); AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault(); _songAudio = AudioTimeSync.GetPrivateField <AudioSource>("_audioSource"); PracticeMode = (_levelData.Mode == BS_Utils.Gameplay.Mode.Standard && _levelData.GameplayCoreSceneSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel && Resources.FindObjectsOfTypeAll <MissionLevelGameplayManager>().FirstOrDefault() == null); if (!PracticeMode) { _timeScale = Mathf.Clamp(TimeScale, 1, SpeedMaxSize); } if (PracticeMode) { if (_levelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul != 1f) { _timeScale = _levelData.GameplayCoreSceneSetupData.practiceSettings.songSpeedMul; } else { _timeScale = _levelData.GameplayCoreSceneSetupData.gameplayModifiers.songSpeedMul; } SharedCoroutineStarter.instance.StartCoroutine(DelayedSetup()); } } }