1
0

AudioMain.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using MelonLoader;
  2. using Il2CppInterop.Runtime.Injection;
  3. using Il2Cpp;
  4. using UnityEngine;
  5. using UnityEngine.Rendering;
  6. namespace AudioMgr
  7. {
  8. public class AudioMain : MelonMod
  9. {
  10. bool initialized = false;
  11. ClipManager myClipManager, myClipManager2;
  12. Shot myPlayerShot;
  13. string rootPath = Application.dataPath + "/../Mods/";
  14. //AssetBundle bundle;
  15. public static bool _debug = false;
  16. public override void OnInitializeMelon()
  17. {
  18. ClassInjector.RegisterTypeInIl2Cpp<Shot>();
  19. ClassInjector.RegisterTypeInIl2Cpp<Queue>();
  20. AudioMgr.Settings.OnLoad();
  21. //bundle = AssetBundle.LoadFromFile(Application.dataPath + "/../Mods/sillysounds.unity3d");
  22. }
  23. public override void OnSceneWasLoaded(int buildIndex, string sceneName)
  24. {
  25. if (sceneName.Contains("Boot"))
  26. {
  27. AudioMaster.CreateMasterParent();
  28. //myClipManager = new ClipManager();
  29. //myClipManager2 = new ClipManager();
  30. //myClipManager.LoadClipFromFile("start", "start.mp3", ClipManager.LoadType.Decompressed);
  31. //myClipManager.LoadClipFromFile("shutdown", "shutdown.mp3", ClipManager.LoadType.Decompressed);
  32. //myClipManager.LoadClipFromFile("waterfall", "waterfall.ogg", ClipManager.LoadType.Decompressed);
  33. //myClipManager2.LoadAllClipsFromBundle(bundle);
  34. }
  35. if (sceneName.Contains("Menu"))
  36. {
  37. initialized = true;
  38. //myPlayerShot = AudioMaster.CreatePlayerShot(AudioMaster.SourceType.SFX);
  39. //PatchMaster.AddReplacePatch("PLAY_CROWCAWSDISTANT", myClipManager, "start", AudioMaster.SourceType.SFX);
  40. //PatchMaster.AddReplacePatch("PLAY_SNDMECHDOORWOODCLOSE1", myClipManager, "shutdown", AudioMaster.SourceType.SFX);
  41. }
  42. }
  43. public override void OnFixedUpdate()
  44. {
  45. if (initialized)
  46. {
  47. AudioMaster.MoveMasterToPlayer();
  48. }
  49. }
  50. public override void OnUpdate()
  51. {
  52. if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.Keypad0))
  53. {
  54. // myPlayerShot.PlayOneshot(myClipManager.GetClip("waterfall"));
  55. PatchMaster.AddSkipPatch("PLAY_RANDOMBUILDINGCREAKS1");
  56. PatchMaster.AddParameterPatch("WINDGUSTINTENSITY", 0f, PatchMaster.ParameterType.Limitter);
  57. PatchMaster.AddParameterPatch("WINDACTUALSPEED", 0f, PatchMaster.ParameterType.Limitter);
  58. PatchMaster.AddParameterPatch("AMBIENTVOLUME", 0f, PatchMaster.ParameterType.Limitter);
  59. PatchMaster.AddParameterPatch("GLOBALVOLUME", 0f, PatchMaster.ParameterType.Limitter);
  60. }
  61. if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.L))
  62. {
  63. //myPlayerShot.PlayOneshot(myClipManager2.GetClip("woo"));
  64. }
  65. }
  66. }
  67. }