1
0

AudioMain.cs 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. ClassInjector.RegisterTypeInIl2Cpp<Stream>();
  21. RadioMaster.Initialize();
  22. AudioMgr.Settings.OnLoad();
  23. //bundle = AssetBundle.LoadFromFile(Application.dataPath + "/../Mods/sillysounds.unity3d");
  24. }
  25. public override void OnSceneWasLoaded(int buildIndex, string sceneName)
  26. {
  27. if (sceneName.Contains("Boot"))
  28. {
  29. AudioMaster.CreateMasterParent();
  30. //myClipManager = new ClipManager();
  31. //myClipManager2 = new ClipManager();
  32. //myClipManager.LoadClipFromFile("start", "start.mp3", ClipManager.LoadType.Decompressed);
  33. //myClipManager.LoadClipFromFile("shutdown", "shutdown.mp3", ClipManager.LoadType.Decompressed);
  34. //myClipManager.LoadClipFromFile("waterfall", "waterfall.ogg", ClipManager.LoadType.Decompressed);
  35. //myClipManager2.LoadAllClipsFromBundle(bundle);
  36. }
  37. if (sceneName.Contains("Menu"))
  38. {
  39. initialized = true;
  40. //myPlayerShot = AudioMaster.CreatePlayerShot(AudioMaster.SourceType.SFX);
  41. //PatchMaster.AddReplacePatch("PLAY_CROWCAWSDISTANT", myClipManager, "start", AudioMaster.SourceType.SFX);
  42. //PatchMaster.AddReplacePatch("PLAY_SNDMECHDOORWOODCLOSE1", myClipManager, "shutdown", AudioMaster.SourceType.SFX);
  43. }
  44. }
  45. public override void OnFixedUpdate()
  46. {
  47. if (initialized)
  48. {
  49. AudioMaster.MoveMasterToPlayer();
  50. }
  51. }
  52. public override void OnUpdate()
  53. {
  54. if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.Keypad0))
  55. {
  56. // myPlayerShot.PlayOneshot(myClipManager.GetClip("waterfall"));
  57. PatchMaster.AddSkipPatch("PLAY_RANDOMBUILDINGCREAKS1");
  58. PatchMaster.AddParameterPatch("WINDGUSTINTENSITY", 0f, PatchMaster.ParameterType.Limitter);
  59. PatchMaster.AddParameterPatch("WINDACTUALSPEED", 0f, PatchMaster.ParameterType.Limitter);
  60. PatchMaster.AddParameterPatch("AMBIENTVOLUME", 0f, PatchMaster.ParameterType.Limitter);
  61. PatchMaster.AddParameterPatch("GLOBALVOLUME", 0f, PatchMaster.ParameterType.Limitter);
  62. }
  63. if (InputManager.GetKeyDown(InputManager.m_CurrentContext, KeyCode.L))
  64. {
  65. //myPlayerShot.PlayOneshot(myClipManager2.GetClip("woo"));
  66. }
  67. }
  68. }
  69. }