static bool Prefix(SaberClashChecker ____saberClashChecker, HapticFeedbackController ____hapticFeedbackController, ref SaberClashEffect __instance, ParticleSystem ____glowParticleSystem, ref ParticleSystem.EmissionModule ____sparkleParticleSystemEmmisionModule, ref ParticleSystem.EmissionModule ____glowParticleSystemEmmisionModule, ref bool ____sabersAreClashing) { if (!PluginConfig.saberClash && PluginConfig.enabled) { if (____saberClashChecker.sabersAreClashing) { __instance.transform.position = ____saberClashChecker.clashingPoint; // ____hapticFeedbackController.ContinuousRumble(XRNode.LeftHand); // ____hapticFeedbackController.ContinuousRumble(XRNode.RightHand); if (!____sabersAreClashing) { ____sabersAreClashing = true; ____sparkleParticleSystemEmmisionModule.enabled = true; ____glowParticleSystemEmmisionModule.enabled = true; return(true); } } else if (____sabersAreClashing) { ____sabersAreClashing = false; ____sparkleParticleSystemEmmisionModule.enabled = false; ____glowParticleSystemEmmisionModule.enabled = false; ____glowParticleSystem.Clear(); } return(false); } else { return(true); } }
public void foundEffectManager() { effectManager.sparkleEffectDidStartEvent += onSparkleEffectStart; effectManager.sparkleEffectDidEndEvent += onSparkleEffectEnd; haptics = effectManager.getPrivateField <HapticFeedbackController>("_hapticFeedbackController"); left = effectManager.getPrivateField <Saber[]>("_sabers")[0]; }
static bool Prefix(SaberType saberType, HapticFeedbackController ____hapticFeedbackController, HapticPresetSO ____rumblePreset) { //Logger.log.Debug($"NoteCutHapticEffect: strengh={____rumblePreset._strength}, duration={____rumblePreset._duration}, frequency={____rumblePreset._frequency}, continuous={____rumblePreset._continuous}"); if ((Configuration.PluginConfig.Instance.strength > 0) && (Configuration.PluginConfig.Instance.duration > 0)) { ____hapticFeedbackController.PlayHapticFeedback(saberType.Node(), rumblePreset); } return(false); }
public void OnDisable() { if (effectManager != null) { effectManager.sparkleEffectDidStartEvent -= onSparkleEffectStart; effectManager.sparkleEffectDidEndEvent -= onSparkleEffectEnd; effectManager = null; haptics = null; } }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public static void Rumble(HapticFeedbackController t, XRNode node, float duration, float impulseLength, float intervalTime) { if (!ReflectionUtil.GetPrivateField <MainSettingsModel>(t, "_mainSettingsModel").controllersRumbleEnabled) { return; } if (Plugin.IsOneHanded && node == XRNode.LeftHand) { node = XRNode.RightHand; } SharedCoroutineStarter.instance.StartCoroutine(t.OneShotRumbleCoroutine(node, duration, impulseLength, intervalTime)); }
static bool Prefix(HapticFeedbackController __instance, XRNode node) { if (PluginConfig.Instance.Enabled && PluginConfig.Instance.disableRumble) { if (node == XRNode.LeftHand && PluginConfig.Instance.isLeftRemoteSaber) { return(false); } else if (node == XRNode.RightHand && !PluginConfig.Instance.isLeftRemoteSaber) { return(false); } } return(true); }
public static void Rumble(HapticFeedbackController t, XRNode node, float duration, float impulseStrength, float intervalDuration) { if (!ReflectionUtil.GetPrivateField <BoolSO>(t, "_controllersRumbleEnabled").value) { return; } if (Plugin.IsOneHanded) { if (Plugin.MainController == ControllerType.RIGHT && node == XRNode.LeftHand) { node = XRNode.RightHand; } else if (Plugin.MainController == ControllerType.LEFT && node == XRNode.RightHand) { node = XRNode.LeftHand; } } SharedCoroutineStarter.instance.StartCoroutine(t.OneShotRumbleCoroutine(node, duration, impulseStrength, intervalDuration)); }
private static void Prefix(HapticFeedbackController __instance, ref XRNode node) { if (ConfigOptions.instance.PlayMode != PlayMode.DarthMaul || ConfigOptions.instance.DarthMaulControllerCount != ControllerCountEnum.One || DarthMaulBehavior.Split) { // Let the original function handle the haptic feedback return; } if (!ConfigOptions.instance.UseLeftController && node == XRNode.LeftHand) { node = XRNode.RightHand; } if (ConfigOptions.instance.UseLeftController && node == XRNode.RightHand) { node = XRNode.LeftHand; } }
private static void Prefix(HapticFeedbackController __instance, ref XRNode node) { if (Configuration.instance.ConfigurationData.PlayMode != PlayMode.DarthMaul || BehaviorCatalog.instance.DarthMaulBehavior == null || BehaviorCatalog.instance.DarthMaulBehavior.Split) { // Let the original function handle the haptic feedback return; } if (Configuration.instance.ConfigurationData.DarthMaulControllerCount == ControllerCountEnum.One) { if (!Configuration.instance.ConfigurationData.UseLeftController && node == XRNode.LeftHand) { // Using right controller, move left hits to right hand node = XRNode.RightHand; } if (Configuration.instance.ConfigurationData.UseLeftController && node == XRNode.RightHand) { // Using left controller, move right hits to left hand node = XRNode.LeftHand; } return; } if (Configuration.instance.ConfigurationData.DarthMaulControllerCount == ControllerCountEnum.Two && Configuration.instance.ConfigurationData.ReverseMaulDirection) { // If reversing direction with two controller then always swap hands if (node == XRNode.LeftHand) { node = XRNode.RightHand; } if (node == XRNode.RightHand) { node = XRNode.LeftHand; } } }
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; } }
private IEnumerator Start() { yield return(FindComponentInBeatSaber(SearchTimeout, (HapticFeedbackController Result) => HapticFeedbackController = Result)); yield return(FindComponentInBeatSaber(SearchTimeout, (NoteCutEffectSpawner Result) => NoteCutEffectSpawner = Result)); if (HapticFeedbackController == null) { Logger.log.Error("Haptic Feedback Controller not found!"); yield break; } if (NoteCutEffectSpawner == null) { Logger.log.Error("Note Cut Spawner not found!"); yield break; } FieldInfo field = NoteCutEffectSpawner.GetType().GetField("_beatmapObjectSpawnController", BindingFlags.Instance | BindingFlags.NonPublic); BeatmapObjectSpawnController = field.GetValue(NoteCutEffectSpawner) as BeatmapObjectSpawnController; if (BeatmapObjectSpawnController == null) { Logger.log.Error("Beatmap object spawner not found"); yield break; } BeatmapObjectSpawnController.noteWasCutEvent += BeatmapObjectSpawnController_noteWasCutEvent; }
static bool Prefix(ActiveObstaclesManager ____activeObstaclesManager, ObstacleSaberSparkleEffect ____obstacleSaberSparkleEffectPefab, PlayerController ____playerController, HapticFeedbackController ____hapticFeedbackController, ref Saber[] ____sabers, ref ObstacleSaberSparkleEffect[] ____effects, ref Transform[] ____effectsTransforms, ref bool[] ____isSystemActive, ref bool[] ____wasSystemActive, ref Vector3[] ____burnMarkPositions, ObstacleSaberSparkleEffectManager __instance) { if (!PluginConfig.obstacleRumble && PluginConfig.enabled) { ____wasSystemActive[0] = ____isSystemActive[0]; ____wasSystemActive[1] = ____isSystemActive[1]; ____isSystemActive[0] = false; ____isSystemActive[1] = false; foreach (ObstacleController obstacleController in ____activeObstaclesManager.activeObstacleControllers) { Bounds bounds = obstacleController.bounds; for (int i = 0; i < 2; i++) { Vector3 vector; if (____sabers[i].isActiveAndEnabled && __instance.GetBurnMarkPos(bounds, obstacleController.transform, ____sabers[i].saberBladeBottomPos, ____sabers[i].saberBladeTopPos, out vector)) { ____isSystemActive[i] = true; ____burnMarkPositions[i] = vector; ____effects[i].SetPositionAndRotation(vector, __instance.GetEffectRotation(vector, obstacleController.transform, bounds)); XRNode node = (i == 0) ? XRNode.LeftHand : XRNode.RightHand; //____hapticFeedbackController.ContinuousRumble(node); if (!____wasSystemActive[i]) { ____effects[i].StartEmission(); __instance.GetPrivateField <Action <Saber.SaberType> >("sparkleEffectDidStartEvent")(____sabers[i].saberType); } } } } for (int j = 0; j < 2; j++) { if (!____isSystemActive[j] && ____wasSystemActive[j]) { ____effects[j].StopEmission(); __instance.GetPrivateField <Action <Saber.SaberType> >("sparkleEffectDidEndEvent")(____sabers[j].saberType); } } return(false); } else { return(true); } }