private void SceneManagerOnActiveSceneChanged(Scene arg0, Scene scene) { try { this._playerController = FindObjectOfType <PlayerController>(); if (scene.buildIndex == 1) { IsLeftSaberOn = true; if (_beatmapObjectSpawnController != null) { _beatmapObjectSpawnController.noteWasCutEvent -= this.HandleNoteWasCutEvent; } if (_mainSettingsModel != null && stored) { StartCoroutine(RestoreNoEnergy()); } } if (scene.buildIndex == 5) { var _mainGameSceneSetup = FindObjectOfType <MainGameSceneSetup>(); this._gameSongController = FindObjectOfType <GameSongController>(); this._noteCutEffectSpawner = FindObjectOfType <NoteCutEffectSpawner>(); this._beatmapObjectSpawnController = FindObjectOfType <BeatmapObjectSpawnController>(); _noteCutHapticEffect = ReflectionUtil.GetPrivateField <NoteCutHapticEffect>(_noteCutEffectSpawner, "_noteCutHapticEffect"); _hapticFeedbackController = ReflectionUtil.GetPrivateField <HapticFeedbackController>(_noteCutHapticEffect, "_hapticFeedbackController"); _mainSettingsModel = ReflectionUtil.GetPrivateField <MainSettingsModel>(_hapticFeedbackController, "_mainSettingsModel"); _mainSettingsModel.controllersRumbleEnabled = true; this._mainGameSceneSetupData = ReflectionUtil.GetPrivateField <MainGameSceneSetupData>(_mainGameSceneSetup, "_mainGameSceneSetupData"); if (!stored) { storedNoEnergy = _mainGameSceneSetupData.gameplayOptions.noEnergy; } stored = true; if (_mainGameSceneSetupData.gameplayMode == GameplayMode.SoloNoArrows) { BeatmapDataModel _beatmapDataModel = ReflectionUtil.GetPrivateField <BeatmapDataModel>(_mainGameSceneSetup, "_beatmapDataModel"); BeatmapData beatmapData = CreateTransformedBeatmapData(_mainGameSceneSetupData.difficultyLevel.beatmapData, _mainGameSceneSetupData.gameplayOptions, _mainGameSceneSetupData.gameplayMode); if (beatmapData != null) { _beatmapDataModel.beatmapData = beatmapData; ReflectionUtil.SetPrivateField(_mainGameSceneSetup, "_beatmapDataModel", _beatmapDataModel); } if (Plugin.IsOneColorModeOn) { _mainGameSceneSetupData.gameplayOptions.noEnergy = true; _sabers = FindObjectsOfType <Saber>(); Saber targetSaber = (Plugin.IsColorRed) ? _playerController.leftSaber : _playerController.rightSaber; Saber otherSaber = (Plugin.IsColorRed) ? _playerController.rightSaber : _playerController.leftSaber; if (targetSaber == null || otherSaber == null) { return; } var targetCopy = Instantiate(targetSaber.gameObject); Saber newSaber = targetCopy.GetComponent <Saber>(); targetCopy.transform.parent = targetSaber.transform.parent; targetCopy.transform.localPosition = Vector3.zero; targetCopy.transform.localRotation = Quaternion.identity; targetSaber.transform.parent = otherSaber.transform.parent; targetSaber.transform.localPosition = Vector3.zero; targetSaber.transform.localRotation = Quaternion.identity; otherSaber.gameObject.SetActive(false); if (Plugin.IsColorRed) { ReflectionUtil.SetPrivateField(_playerController, "_rightSaber", targetSaber); ReflectionUtil.SetPrivateField(_playerController, "_leftSaber", newSaber); } else { ReflectionUtil.SetPrivateField(_playerController, "_leftSaber", targetSaber); ReflectionUtil.SetPrivateField(_playerController, "_rightSaber", newSaber); } _playerController.leftSaber.gameObject.SetActive(IsLeftSaberOn); if (_beatmapObjectSpawnController != null) { _beatmapObjectSpawnController.noteWasCutEvent += this.HandleNoteWasCutEvent; } } } } } catch (Exception ex) { Console.WriteLine(ex.Message + "\n" + ex.StackTrace); } }
private void SpawnController_ScaleRemoveCut(BeatmapObjectSpawnController arg1, INoteController controller, NoteCutInfo arg3) { NoteData note = controller.noteData; Transform noteTransform = controller.noteTransform; // Log("DESPAWN" + noteTransform.localScale.ToString()); if (noteTransform.localScale.x != 1) { noteTransform.localScale = new Vector3(1f, 1f, 1f); } // Log("DESPAWN" + noteTransform.localScale.ToString()); // if (modifiedNotes[note.id] != null) // note = modifiedNotes[note.id]; FloatBehavior behavior = noteTransform.gameObject.GetComponent <FloatBehavior>(); if (behavior != null) { noteTransform.localPosition = new Vector3(behavior.originalX, behavior.originalY, noteTransform.localPosition.z); GameObject.Destroy(behavior); } if (GMPUI.oneColor) { if (!defaultRumble) { return; } _noteCutEffectSpawner = UnityEngine.Object.FindObjectOfType <NoteCutEffectSpawner>(); if (_noteCutEffectSpawner != null) { _noteCutHapticEffect = ReflectionUtil.GetPrivateField <NoteCutHapticEffect>(_noteCutEffectSpawner, "_noteCutHapticEffect"); } if (_noteCutHapticEffect != null) { _hapticFeedbackController = ReflectionUtil.GetPrivateField <HapticFeedbackController>(_noteCutHapticEffect, "_hapticFeedbackController"); } if (_hapticFeedbackController != null) { _RumbleEnabledOneC = ReflectionUtil.GetPrivateField <BoolSO>(_hapticFeedbackController, "_controllersRumbleEnabled"); } if (_RumbleEnabledOneC == null) { return; } Vector3 notePos = controller.noteTransform.position; Vector3 leftPos = player.leftSaber.transform.position; leftPos += player.leftSaber.transform.forward * 0.5f; Vector3 rightPos = player.rightSaber.transform.position; rightPos += player.rightSaber.transform.forward * 0.5f; float leftDist = Vector3.Distance(leftPos, notePos); float rightDist = Vector3.Distance(rightPos, notePos); // Log(leftDist.ToString() + " " + rightDist.ToString()); _RumbleEnabledOneC.value = true; Saber.SaberType targetType = (leftDist > rightDist) ? Saber.SaberType.SaberB : Saber.SaberType.SaberA; if (!(Mathf.Abs(leftDist - rightDist) <= 0.2f)) { _noteCutHapticEffect.HitNote(targetType); } else { _noteCutHapticEffect.HitNote(Saber.SaberType.SaberA); _noteCutHapticEffect.HitNote(Saber.SaberType.SaberB); } _RumbleEnabledOneC.value = false; } }