1
0

PlaySoundPatches.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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(go == null)
  36. {
  37. return true;
  38. }
  39. if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
  40. {
  41. return false;
  42. }
  43. return true;
  44. }
  45. }
  46. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "PlaySound", new Type[] { typeof(Il2CppAK.Wwise.Event), typeof(GameObject) })]
  47. public class PlaySoundPatchEvent
  48. {
  49. public static bool Prefix(ref GameAudioManager __instance, ref Il2CppAK.Wwise.Event soundEvent, ref GameObject go)
  50. {
  51. if (AudioMain._debug)
  52. MelonLogger.Msg("Play event " + soundEvent.Name + " on " + go.name);
  53. if (go == null || soundEvent == null)
  54. {
  55. return true;
  56. }
  57. if (Settings.options.disableWaterfall && soundEvent.Name.Contains("Waterfall"))
  58. {
  59. return false;
  60. }
  61. if (PatchMaster.PatchAction(soundEvent.Name, go))
  62. {
  63. return false;
  64. }
  65. return true;
  66. }
  67. }
  68. }