Beispiel #1
0
        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;
            //                 });
        }
Beispiel #2
0
        void ReplaceControllers()
        {
            if (!Config.Instance.SpectatorMode || Client.Instance.inRadioMode)
            {
                return;
            }

            audioTimeSync    = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
            _songAudioSource = audioTimeSync.GetPrivateField <AudioSource>("_audioSource");

            _leftSaber      = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberB);
            _leftController = _leftSaber.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            _leftSaber.SetPrivateField("_vrController", _leftController);

            _rightSaber      = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberA);
            _rightController = _rightSaber.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            _rightSaber.SetPrivateField("_vrController", _rightController);

            Plugin.log.Info("Controllers replaced!");

            _scoreController = FindObjectOfType <ScoreController>();

#if DEBUG
            _scoreController.noteWasMissedEvent += _scoreController_noteWasMissedEvent;
            _scoreController.noteWasCutEvent    += _scoreController_noteWasCutEvent;
#endif

            Plugin.log.Info("Score controller found!");

            _energyCounter = FindObjectOfType <GameEnergyCounter>();

            Plugin.log.Info("Energy counter found!");
        }
Beispiel #3
0
        IEnumerator WaitForControllers()
        {
            if (!Config.Instance.SpectatorMode || Client.Instance.InRadioMode)
            {
                yield break;
            }

            Misc.Logger.Info("Waiting for controllers...");
            yield return(new WaitWhile(delegate() { return !Resources.FindObjectsOfTypeAll <Saber>().Any(); }));

            audioTimeSync    = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
            _songAudioSource = audioTimeSync.GetPrivateField <AudioSource>("_audioSource");

            var saberB = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberB);

            _leftController = saberB.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            saberB.SetPrivateField("_vrController", _leftController);

            var saberA = Resources.FindObjectsOfTypeAll <Saber>().First(x => x.saberType == Saber.SaberType.SaberA);

            _rightController = saberA.GetPrivateField <VRController>("_vrController").gameObject.AddComponent <OnlineVRController>();
            saberA.SetPrivateField("_vrController", _rightController);

            _playerController = Resources.FindObjectsOfTypeAll <PlayerController>().First();

            Misc.Logger.Info("Controllers found!");

            _scoreController = FindObjectOfType <ScoreController>();

            Misc.Logger.Info("Score controller found!");
        }
Beispiel #4
0
        private void OneSceneChanged(Scene oldScene, Scene newScene)
        {
            Object.Destroy(Resources.FindObjectsOfTypeAll <UIElementsCreator>().FirstOrDefault()?.gameObject);
            if (newScene.name == MenuSceneName)
            {
                if (_resetNoFail)
                {
                    var resultsViewController =
                        Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();
                    if (resultsViewController != null)
                    {
                        resultsViewController.continueButtonPressedEvent +=
                            ResultsViewControllerOnContinueButtonPressedEvent;
                    }
                }

                if (SpeedSettingsObject != null)
                {
                    return;
                }

                var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();

                if (volumeSettings == null)
                {
                    return;
                }

                volumeSettings.gameObject.SetActive(false);
                SpeedSettingsObject = Object.Instantiate(volumeSettings.gameObject);
                SpeedSettingsObject.SetActive(false);
                volumeSettings.gameObject.SetActive(true);

                if (SpeedSettingsObject == null)
                {
                    return;
                }

                var volume = SpeedSettingsObject.GetComponent <VolumeSettingsController>();
                ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController),
                                             typeof(SpeedSettingsController), SpeedSettingsObject);
                Object.DestroyImmediate(volume);

                SpeedSettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                Object.DontDestroyOnLoad(SpeedSettingsObject);


                //NJS Object
                if (NjsSettingsObject != null)
                {
                    return;
                }

                var volumeSettings2 = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();

                if (volumeSettings2 == null)
                {
                    return;
                }

                volumeSettings2.gameObject.SetActive(false);
                NjsSettingsObject = Object.Instantiate(volumeSettings2.gameObject);
                NjsSettingsObject.SetActive(false);
                volumeSettings2.gameObject.SetActive(true);

                if (NjsSettingsObject == null)
                {
                    return;
                }

                var volume2 = NjsSettingsObject.GetComponent <VolumeSettingsController>();
                ReflectionUtil.CopyComponent(volume2, typeof(IncDecSettingsController),
                                             typeof(NjsSettingsController), NjsSettingsObject);
                Object.DestroyImmediate(volume2);

                NjsSettingsObject.GetComponentInChildren <TMP_Text>().text = "NJS";
                Object.DontDestroyOnLoad(NjsSettingsObject);


                //Spawn Offset Object
                if (SpawnOffsetSettingsObject != null)
                {
                    return;
                }

                var volumeSettings3 = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();

                if (volumeSettings3 == null)
                {
                    return;
                }

                volumeSettings3.gameObject.SetActive(false);
                SpawnOffsetSettingsObject = Object.Instantiate(volumeSettings3.gameObject);
                SpawnOffsetSettingsObject.SetActive(false);
                volumeSettings3.gameObject.SetActive(true);

                if (SpawnOffsetSettingsObject == null)
                {
                    return;
                }

                var volume3 = SpawnOffsetSettingsObject.GetComponent <VolumeSettingsController>();
                ReflectionUtil.CopyComponent(volume3, typeof(IncDecSettingsController),
                                             typeof(SpawnOffsetController), SpawnOffsetSettingsObject);
                Object.DestroyImmediate(volume3);

                SpawnOffsetSettingsObject.GetComponentInChildren <TMP_Text>().text = "Spawn Offset";
                Object.DontDestroyOnLoad(SpawnOffsetSettingsObject);
            }
            else if (newScene.name == GameSceneName)
            {
                CustomEffectPoolsInstaller customEffectPoolsInstaller = null;
                var effectPoolsInstaller = Resources.FindObjectsOfTypeAll <EffectPoolsInstaller>().FirstOrDefault();
                if (effectPoolsInstaller != null)
                {
                    customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller,
                                                                                                          typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject);
                }

                SceneContext          sceneContext          = null;
                SceneDecoratorContext sceneDecoratorContext = null;
                try
                {
                    Console.WriteLine("Custom effect Pool Installer Made");
                    foreach (var gameObject in newScene.GetRootGameObjects())
                    {
                        if (sceneContext == null)
                        {
                            sceneContext = gameObject.GetComponentInChildren <SceneContext>(true);
                        }
                    }

                    foreach (var gameObject in SceneManager.GetSceneByName(ContextSceneName).GetRootGameObjects())
                    {
                        if (sceneDecoratorContext == null)
                        {
                            sceneDecoratorContext = gameObject.GetComponentInChildren <SceneDecoratorContext>(true);
                        }
                    }


                    if (sceneContext != null && sceneDecoratorContext != null)
                    {
                        var prop           = typeof(Context).GetField("_installers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                        var installersList = (List <MonoInstaller>)prop.GetValue(sceneDecoratorContext);
                        installersList.Remove(effectPoolsInstaller);
                        Object.DestroyImmediate(effectPoolsInstaller);
                        installersList.Add(customEffectPoolsInstaller);
                        Console.WriteLine("Custom effect Pool Installer Added");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }


                if (_levelData == null)
                {
                    _levelData = Resources.FindObjectsOfTypeAll <StandardLevelSceneSetupDataSO>().FirstOrDefault();
                    if (_levelData == null)
                    {
                        return;
                    }
                    _levelData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent;
                }

                if (_spawnController == null)
                {
                    _spawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault();
                }


                if (_lastLevelId != _levelData.difficultyBeatmap.level.levelID &&
                    !string.IsNullOrEmpty(_lastLevelId))
                {
                    PlayingNewSong      = true;
                    HasTimeScaleChanged = false;
                    TimeScale           = 1;
                    _lastLevelId        = _levelData.difficultyBeatmap.level.levelID;
                }
                else
                {
                    PlayingNewSong = false;
                }

                if (IsEqualToOne(TimeScale))
                {
                    HasTimeScaleChanged = false;
                }

                _lastLevelId        = _levelData.difficultyBeatmap.level.levelID;
                _gameCoreSceneSetup = Resources.FindObjectsOfTypeAll <GameplayCoreSceneSetup>().FirstOrDefault();
                AudioTimeSync       = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _songAudio          = AudioTimeSync.GetPrivateField <AudioSource>("_audioSource");
                _mixer       = _gameCoreSceneSetup.GetPrivateField <AudioMixerSO>("_audioMixer");
                PracticeMode = (_levelData.gameplayCoreSetupData.practiceSettings != null && !BS_Utils.Gameplay.Gamemode.IsIsolatedLevel);
                //Check if Multiplayer is active, disable accordingly
                if (PluginManager.Plugins.Any(x => x.Name == "Beat Saber Multiplayer"))
                {
                    GameObject client = GameObject.Find("MultiplayerClient");
                    if (client != null)
                    {
                        Console.WriteLine("[PracticePlugin] Found MultiplayerClient game object!");
                        multiActive = true;
                    }
                    else
                    {
                        Console.WriteLine("[PracticePlugin] MultiplayerClient game object not found!");
                    }
                }
                if (multiActive == true)
                {
                    PracticeMode = false;
                }


                if (!PracticeMode)
                {
                    TimeScale = Mathf.Clamp(TimeScale, 1, SpeedMaxSize);
                }
                if (PracticeMode)
                {
                    if (_levelData.gameplayCoreSetupData.practiceSettings.songSpeedMul != 1f)
                    {
                        _timeScale = _levelData.gameplayCoreSetupData.practiceSettings.songSpeedMul;
                    }
                    else
                    {
                        _timeScale = _levelData.gameplayCoreSetupData.gameplayModifiers.songSpeedMul;
                    }
                    SharedCoroutineStarter.instance.StartCoroutine(DelayedUI());
                }
            }
        }
        private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene)
        {
            if (scene.buildIndex == 1)
            {
                if (_resetNoFail)
                {
                    var resultsViewController =
                        Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();
                    resultsViewController.continueButtonPressedEvent += ResultsViewControllerOnContinueButtonPressedEvent;
                }

                if (SettingsObject == null)
                {
                    var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();
                    volumeSettings.gameObject.SetActive(false);
                    SettingsObject = Object.Instantiate(volumeSettings.gameObject);
                    SettingsObject.SetActive(false);
                    volumeSettings.gameObject.SetActive(true);
                    var volume = SettingsObject.GetComponent <VolumeSettingsController>();
                    ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController),
                                                 typeof(SpeedSettingsController), SettingsObject);
                    Object.DestroyImmediate(volume);
                    SettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                    Object.DontDestroyOnLoad(SettingsObject);
                }
            }
            else
            {
                if (_mainGameSceneSetupData == null)
                {
                    _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                    if (_mainGameSceneSetupData == null)
                    {
                        return;
                    }
                    _mainGameSceneSetupData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent;
                }

                if (scene.buildIndex != 5)
                {
                    return;
                }

                if (_lastLevelId != _mainGameSceneSetupData.difficultyLevel.level.levelID &&
                    !string.IsNullOrEmpty(_lastLevelId))
                {
                    HasTimeScaleChanged = false;
                    TimeScale           = 1;
                    _lastLevelId        = _mainGameSceneSetupData.difficultyLevel.level.levelID;
                }

                if (IsEqualToOne(TimeScale))
                {
                    HasTimeScaleChanged = false;
                }

                _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID;

                _audioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _songAudio     = _audioTimeSync.GetPrivateField <AudioSource>("_audioSource");
                NoFail         = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse;

                if (!NoFail)
                {
                    TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize);
                }

                NoteHitPitchChanger.ReplacePrefab();

                var canvas = Resources.FindObjectsOfTypeAll <HorizontalLayoutGroup>()
                             .FirstOrDefault(x => x.name == "Buttons")
                             .transform.parent;
                _speedSettingsCreator = canvas.gameObject.AddComponent <SpeedSettingsCreator>();
                _speedSettingsCreator.ValueChangedEvent += SpeedSettingsCreatorOnValueChangedEvent;
                TimeScale = TimeScale;
            }
        }
Beispiel #6
0
        private void SceneManagerOnSceneLoaded(Scene scene, LoadSceneMode mode)
        {
            if (scene.name == MenuSceneName)
            {
                if (_resetNoFail)
                {
                    var resultsViewController =
                        Resources.FindObjectsOfTypeAll <ResultsViewController>().FirstOrDefault();
                    if (resultsViewController != null)
                    {
                        resultsViewController.continueButtonPressedEvent +=
                            ResultsViewControllerOnContinueButtonPressedEvent;
                    }
                }

                if (SettingsObject != null)
                {
                    return;
                }

                var volumeSettings = Resources.FindObjectsOfTypeAll <VolumeSettingsController>().FirstOrDefault();

                if (volumeSettings == null)
                {
                    return;
                }

                volumeSettings.gameObject.SetActive(false);
                SettingsObject = Object.Instantiate(volumeSettings.gameObject);
                SettingsObject.SetActive(false);
                volumeSettings.gameObject.SetActive(true);

                if (SettingsObject == null)
                {
                    return;
                }

                var volume = SettingsObject.GetComponent <VolumeSettingsController>();
                ReflectionUtil.CopyComponent(volume, typeof(IncDecSettingsController),
                                             typeof(SpeedSettingsController), SettingsObject);
                Object.DestroyImmediate(volume);

                SettingsObject.GetComponentInChildren <TMP_Text>().text = "SPEED";
                Object.DontDestroyOnLoad(SettingsObject);
            }
            else if (scene.name == GameSceneName)
            {
                CustomEffectPoolsInstaller customEffectPoolsInstaller = null;
                var effectPoolsInstaller = Resources.FindObjectsOfTypeAll <EffectPoolsInstaller>().FirstOrDefault();
                if (effectPoolsInstaller != null)
                {
                    customEffectPoolsInstaller = (CustomEffectPoolsInstaller)ReflectionUtil.CopyComponent(effectPoolsInstaller,
                                                                                                          typeof(EffectPoolsInstaller), typeof(CustomEffectPoolsInstaller), effectPoolsInstaller.gameObject);
                }

                SceneContext          sceneContext          = null;
                SceneDecoratorContext sceneDecoratorContext = null;

                foreach (var gameObject in scene.GetRootGameObjects())
                {
                    if (sceneContext == null)
                    {
                        sceneContext = gameObject.GetComponentInChildren <SceneContext>(true);
                    }
                }

                foreach (var gameObject in SceneManager.GetSceneByName(ContextSceneName).GetRootGameObjects())
                {
                    if (sceneDecoratorContext == null)
                    {
                        sceneDecoratorContext = gameObject.GetComponentInChildren <SceneDecoratorContext>(true);
                    }
                }


                if (sceneContext != null && sceneDecoratorContext != null)
                {
                    var prop           = typeof(Context).GetField("_installers", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                    var installersList = (List <MonoInstaller>)prop.GetValue(sceneDecoratorContext);
                    installersList.Remove(effectPoolsInstaller);
                    Object.DestroyImmediate(effectPoolsInstaller);
                    installersList.Add(customEffectPoolsInstaller);
                }

                if (_mainGameSceneSetupData == null)
                {
                    _mainGameSceneSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault();
                    if (_mainGameSceneSetupData == null)
                    {
                        return;
                    }
                    _mainGameSceneSetupData.didFinishEvent += MainGameSceneSetupDataOnDidFinishEvent;
                }

                if (_lastLevelId != _mainGameSceneSetupData.difficultyLevel.level.levelID &&
                    !string.IsNullOrEmpty(_lastLevelId))
                {
                    PlayingNewSong      = true;
                    HasTimeScaleChanged = false;
                    TimeScale           = 1;
                    _lastLevelId        = _mainGameSceneSetupData.difficultyLevel.level.levelID;
                }
                else
                {
                    PlayingNewSong = false;
                }

                if (IsEqualToOne(TimeScale))
                {
                    HasTimeScaleChanged = false;
                }

                _lastLevelId = _mainGameSceneSetupData.difficultyLevel.level.levelID;

                AudioTimeSync = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _songAudio    = AudioTimeSync.GetPrivateField <AudioSource>("_audioSource");
                NoFail        = !_mainGameSceneSetupData.gameplayOptions.validForScoreUse;

                if (!NoFail)
                {
                    TimeScale = Mathf.Clamp(TimeScale, 1, MaxSize);
                }

                var canvas = Resources.FindObjectsOfTypeAll <HorizontalLayoutGroup>()
                             .FirstOrDefault(x => x.name == "Buttons")
                             ?.transform.parent;

                if (canvas == null)
                {
                    return;
                }

                _uiElementsCreator = canvas.gameObject.AddComponent <UIElementsCreator>();
                _uiElementsCreator.ValueChangedEvent += UIElementsCreatorOnValueChangedEvent;
                _uiElementsCreator.Init();
                TimeScale = TimeScale;
            }
        }
        private IEnumerator OnGameCoreCoroutine()
        {
            if (_audioTimeSyncController == null)
            {
                _audioTimeSyncController = Resources.FindObjectsOfTypeAll <AudioTimeSyncController>().FirstOrDefault();
                _audioSource             = _audioTimeSyncController.GetPrivateField <AudioSource>("_audioSource");
            }
            _originalTimeScale = _audioTimeSyncController.timeScale;

            if (_gamePause == null)
            {
                _gamePause = Resources.FindObjectsOfTypeAll <GamePause>().FirstOrDefault();
            }
            _gamePause.didResumeEvent += OnPauseResume;

            // wait for CustomSaber mod
            yield return(new WaitUntil(() => Resources.FindObjectsOfTypeAll <Saber>().Any()));

            yield return(new WaitForSecondsRealtime(0.1f));

            if (_playerController == null)
            {
                _playerController = Resources.FindObjectsOfTypeAll <PlayerController>().FirstOrDefault();
            }
            if (_rightSaberTransform == null)
            {
                _rightSaberTransform = _playerController.rightSaber.transform;
            }
            if (_leftSaberTransform == null)
            {
                _leftSaberTransform = _playerController.leftSaber.transform;
            }
            if (_saberClashChecker == null)
            {
                _saberClashChecker = Resources.FindObjectsOfTypeAll <SaberClashChecker>().FirstOrDefault();
            }
            if (_saberBurnMarkArea == null)
            {
                _saberBurnMarkArea = Resources.FindObjectsOfTypeAll <SaberBurnMarkArea>().FirstOrDefault();
            }
            if (_saberBurnMarkSparkles == null)
            {
                _saberBurnMarkSparkles = Resources.FindObjectsOfTypeAll <SaberBurnMarkSparkles>().FirstOrDefault();
            }

            // need some wait to GetNoteOffset
            if (Config.centering)
            {
                if (_beatmapObjectSpawnController == null)
                {
                    _beatmapObjectSpawnController = Resources.FindObjectsOfTypeAll <BeatmapObjectSpawnController>().FirstOrDefault();
                }
                BeatmapObjectSpawnMovementData beatmapObjectSpawnMovementData = _beatmapObjectSpawnController.GetPrivateField <BeatmapObjectSpawnMovementData>("_beatmapObjectSpawnMovementData");
                Vector3 leftBase = beatmapObjectSpawnMovementData.GetNoteOffset(0, NoteLineLayer.Base);
                Vector3 rightTop = beatmapObjectSpawnMovementData.GetNoteOffset(3, NoteLineLayer.Top);
                NoteJumpManualUpdate.center = (leftBase + rightTop) / 2;
                //Logger.log.Debug($"leftBase={leftBase.x}, {leftBase.y}, {leftBase.z}");
                //Logger.log.Debug($"rightTop={rightTop.x}, {rightTop.y}, {rightTop.z}");
            }

            if (Config.hideSabers)
            {
                SetSaberVisible(_playerController.rightSaber, false);
                SetSaberVisible(_playerController.leftSaber, false);
                SetTrailWidth(0f);
                _saberClashChecker.enabled     = false;
                _saberBurnMarkArea.enabled     = false;
                _saberBurnMarkSparkles.enabled = false;
            }

            if (Config.hideSaberEffects)
            {
                SetTrailWidth(0f);
                _saberClashChecker.enabled     = false;
                _saberBurnMarkArea.enabled     = false;
                _saberBurnMarkSparkles.enabled = false;
            }

            if (Config.boxing)
            {
                SetTrailWidth(0.05f);
            }

            if (Config.headbang)
            {
                SetTrailWidth(0f);
            }

            if (Config.vacuum)
            {
                if (_gameEnergyCounter == null)
                {
                    _gameEnergyCounter = Resources.FindObjectsOfTypeAll <GameEnergyCounter>().FirstOrDefault();
                }
                _gameEnergyCounter.SetPrivateField("_hitBombEnergyDrain", 0f);
            }

            if (GameObject.Find("vacuum_saber_right"))
            {
                SetTrailWidth(0f);
            }

            if (Config.feetAvatar)
            {
                StartCoroutine(FindAvatarCoroutine());
            }

            UpdateSaberActive();

            _init = true;
        }
Beispiel #8
0
        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());
                }
            }
        }