PlaySoundPatches.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Il2Cpp;
  2. using Il2CppNodeCanvas.Tasks.Actions;
  3. using MelonLoader;
  4. using UnityEngine;
  5. namespace AudioMgr
  6. {
  7. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "PlaySound", new Type[] { typeof(string), typeof(GameObject)})]
  8. public class PlaySoundPatchString
  9. {
  10. public static bool Prefix(ref GameAudioManager __instance, ref string soundID, ref GameObject go)
  11. {
  12. if (AudioMain._debug)
  13. MelonLogger.Msg("Play string " + soundID + " on " + go.name);
  14. if (Settings.options.disableFlare)
  15. {
  16. if (soundID.Contains("FlareLoop") || soundID.Contains("FLARELIGHT"))
  17. {
  18. return false;
  19. }
  20. }
  21. if (PatchMaster.PatchAction(soundID, go))
  22. {
  23. return false;
  24. }
  25. return true;
  26. }
  27. }
  28. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "PlaySound", new Type[] { typeof(uint), typeof(GameObject) })]
  29. public class PlaySoundPatchUInt
  30. {
  31. public static bool Prefix(ref GameAudioManager __instance, ref uint soundID, ref GameObject go)
  32. {
  33. if (AudioMain._debug)
  34. MelonLogger.Msg("Play uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
  35. if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
  36. {
  37. return false;
  38. }
  39. return true;
  40. }
  41. }
  42. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "PlaySound", new Type[] { typeof(Il2CppAK.Wwise.Event), typeof(GameObject) })]
  43. public class PlaySoundPatchEvent
  44. {
  45. public static bool Prefix(ref GameAudioManager __instance, ref Il2CppAK.Wwise.Event soundEvent, ref GameObject go)
  46. {
  47. if (AudioMain._debug)
  48. MelonLogger.Msg("Play event " + soundEvent.Name + " on " + go.name);
  49. if(Settings.options.disableWaterfall && soundEvent.Name.Contains("Waterfall"))
  50. {
  51. return false;
  52. }
  53. if (PatchMaster.PatchAction(soundEvent.Name, go))
  54. {
  55. return false;
  56. }
  57. return true;
  58. }
  59. }
  60. }