PlaySoundPatches.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. //MelonLogger.Msg("Play string " + soundID + " on " + go.name);
  13. if (PatchMaster.PatchAction(soundID, go))
  14. {
  15. return false;
  16. }
  17. return true;
  18. }
  19. }
  20. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "PlaySound", new Type[] { typeof(uint), typeof(GameObject) })]
  21. public class PlaySoundPatchUInt
  22. {
  23. public static bool Prefix(ref GameAudioManager __instance, ref uint soundID, ref GameObject go)
  24. {
  25. //MelonLogger.Msg("Play uint " + EventIDs.GetEventString(soundID) + " on " + go.name);
  26. if (PatchMaster.PatchAction(EventIDs.GetEventString(soundID), go))
  27. {
  28. return false;
  29. }
  30. return true;
  31. }
  32. }
  33. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "PlaySound", new Type[] { typeof(Il2CppAK.Wwise.Event), typeof(GameObject) })]
  34. public class PlaySoundPatchEvent
  35. {
  36. public static bool Prefix(ref GameAudioManager __instance, ref Il2CppAK.Wwise.Event soundEvent, ref GameObject go)
  37. {
  38. //MelonLogger.Msg("Play event " + soundEvent.Name + " on " + go.name);
  39. if (PatchMaster.PatchAction(soundEvent.Name, go))
  40. {
  41. return false;
  42. }
  43. return true;
  44. }
  45. }
  46. }