RTPCPatches.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using Il2Cpp;
  2. using Il2CppAudio.SimpleAudio;
  3. using MelonLoader;
  4. using UnityEngine;
  5. namespace AudioMgr
  6. {
  7. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "SetRTPCValue", new Type[] { typeof(uint), typeof(float), typeof(GameObject) })]
  8. public class RTPCPatches
  9. {
  10. public static void Prefix(GameAudioManager __instance, ref uint rtpcID, ref float rtpcValue, ref GameObject go)
  11. {
  12. // GAME_PARAMETERS
  13. if (AudioMain._debug)
  14. MelonLogger.Msg("RTPC " + GameParameterIDs.GetString(rtpcID) + "; " + rtpcValue);
  15. if (go == null)
  16. {
  17. return;
  18. }
  19. // Aurora music patch
  20. if (Settings.options.enableAuroraTweaks && GameParameterIDs.GetString(rtpcID) == "AURORASTRENGTH")
  21. {
  22. if (rtpcValue > Settings.options.auroraVolume)
  23. {
  24. rtpcValue = Settings.options.auroraVolume;
  25. }
  26. }
  27. // Wind audioc patch
  28. if (Settings.options.enableWindTweaks && GameManager.GetWeatherComponent().IsIndoorScene() && (GameParameterIDs.GetString(rtpcID) == "WINDINTENSITYBLEND"))
  29. {
  30. if (rtpcValue > Settings.options.windVolume)
  31. {
  32. rtpcValue = Settings.options.windVolume;
  33. }
  34. }
  35. if (VolumeIDs.GetRtpcIDMaster() == rtpcID)
  36. {
  37. VolumeMaster.SetMasterVolume(rtpcValue / 100);
  38. }
  39. else if (VolumeIDs.GetRtpcIDList().ContainsKey(rtpcID)) // Set sfx/voice/ambient/bgm
  40. {
  41. VolumeMaster.SetVolume(VolumeIDs.GetRtpcIDList()[rtpcID], rtpcValue / 100);
  42. }
  43. rtpcValue = PatchMaster.ParameterAction(GameParameterIDs.GetString(rtpcID), rtpcValue);
  44. }
  45. }
  46. }