12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using HarmonyLib;
- using IPA.Utilities;
- using Libraries.HM.HMLib.VR;
- namespace BeatSaberTweakers.HapticFeedbackAdjust.HarmonyPatches
- {
- // void HitNote(SaberType saberType)
- [HarmonyPatch(typeof(NoteCutHapticEffect))]
- [HarmonyPatch("HitNote")]
- [HarmonyPatch(new Type[] { typeof(SaberType) })]
- internal static class NoteCutHapticEffectPatch
- {
- private static readonly HapticPresetSO RumblePreset = new HapticPresetSO
- {
- _continuous = false,
- _duration = 0.14f,
- _strength = 1f,
- _frequency = 1f,
- };
- private static readonly AccessTools.FieldRef<NoteCutHapticEffect, HapticFeedbackController> CtlFieldRef = AccessTools.FieldRefAccess<NoteCutHapticEffect, HapticFeedbackController>("_hapticFeedbackController");
- private static readonly AccessTools.FieldRef<NoteCutHapticEffect, HapticPresetSO> HapticPresetRef = AccessTools.FieldRefAccess<NoteCutHapticEffect, HapticPresetSO>("_rumblePreset");
- static bool Prefix(NoteCutHapticEffect __instance, SaberType saberType)
- {
- var ctl = CtlFieldRef(__instance);
- var hapticPreset = HapticPresetRef(__instance);
- Plugin.Logger.Debug("HitNote:" + saberType + ", s:" + hapticPreset._strength + ", d:" + hapticPreset._duration + ", f:" + hapticPreset._frequency);
- ctl.PlayHapticFeedback(saberType.Node(), RumblePreset);
- return false;
- }
- }
- }
|