AudioMain.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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;
  12. Shot myPlayerShot;
  13. public override void OnInitializeMelon()
  14. {
  15. ClassInjector.RegisterTypeInIl2Cpp<Shot>();
  16. ClassInjector.RegisterTypeInIl2Cpp<Queue>();
  17. }
  18. public override void OnSceneWasLoaded(int buildIndex, string sceneName)
  19. {
  20. if (sceneName.Contains("Boot"))
  21. {
  22. AudioMaster.CreateMasterParent();
  23. myClipManager = new ClipManager();
  24. myClipManager.LoadClipFromFile("start", "start.mp3", ClipManager.LoadType.Decompressed);
  25. myClipManager.LoadClipFromFile("shutdown", "shutdown.mp3", ClipManager.LoadType.Decompressed);
  26. }
  27. if (sceneName.Contains("Menu"))
  28. {
  29. initialized = true;
  30. myPlayerShot = AudioMaster.CreatePlayerShot(AudioMaster.SourceType.Ambience);
  31. PatchMaster.AddReplacePatch("PLAY_SNDMECHDOORWOODOPEN1", myClipManager, "start", AudioMaster.SourceType.SFX);
  32. PatchMaster.AddReplacePatch("PLAY_SNDMECHDOORWOODCLOSE1", myClipManager, "shutdown", AudioMaster.SourceType.SFX);
  33. }
  34. }
  35. public override void OnFixedUpdate()
  36. {
  37. if (initialized)
  38. {
  39. AudioMaster.MoveMasterToPlayer();
  40. }
  41. }
  42. public override void OnUpdate()
  43. {
  44. /*
  45. if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.Keypad0))
  46. {
  47. // myPlayerShot.PlayOneshot(myClipManager.GetClip("waterfall"));
  48. PatchMaster.AddSkipPatch("PLAY_RANDOMBUILDINGCREAKS1");
  49. PatchMaster.AddParameterPatch("WINDGUSTINTENSITY", 0f, PatchMaster.ParameterType.Limitter);
  50. PatchMaster.AddParameterPatch("WINDACTUALSPEED", 0f, PatchMaster.ParameterType.Limitter);
  51. PatchMaster.AddParameterPatch("AMBIENTVOLUME", 0f, PatchMaster.ParameterType.Limitter);
  52. PatchMaster.AddParameterPatch("GLOBALVOLUME", 0f, PatchMaster.ParameterType.Limitter);
  53. }
  54. */
  55. }
  56. }
  57. }