EffectPoolsManualInstallerPatch.cs 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. using HarmonyLib;
  2. using IPA.Utilities;
  3. namespace BeatSaberTweakers.VolumeAdjust.HarmonyPatches
  4. {
  5. [HarmonyPatch(typeof(EffectPoolsManualInstaller), "ManualInstallBindings")]
  6. internal static class EffectPoolsManualInstallerPatch
  7. {
  8. private static readonly FieldAccessor<EffectPoolsManualInstaller, NoteCutSoundEffect>.Accessor GetNoteCutSoundEffect = FieldAccessor<EffectPoolsManualInstaller, NoteCutSoundEffect>.GetAccessor("_noteCutSoundEffectPrefab");
  9. private static readonly FieldAccessor<NoteCutSoundEffect, float>.Accessor GetGoodCutVolume = FieldAccessor<NoteCutSoundEffect, float>.GetAccessor("_goodCutVolume");
  10. private static readonly FieldAccessor<NoteCutSoundEffect, float>.Accessor GetBadCutVolume = FieldAccessor<NoteCutSoundEffect, float>.GetAccessor("_badCutVolume");
  11. internal static void Prefix(EffectPoolsManualInstaller __instance)
  12. {
  13. var eff = GetNoteCutSoundEffect(ref __instance);
  14. var gc = GetGoodCutVolume(ref eff);
  15. var bc = GetBadCutVolume(ref eff);
  16. Plugin.Logger.Debug("EffectPoolsManualInstallerPatch original gc:" + gc + ", bc:" + bc);
  17. gc = 1;
  18. bc = 1;
  19. GetGoodCutVolume(ref eff) = gc;
  20. GetBadCutVolume(ref eff) = bc;
  21. Plugin.Logger.Debug("EffectPoolsManualInstallerPatch to gc:" + gc + ", bc:" + bc);
  22. }
  23. }
  24. }