1
0

RTPCPatches.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. // Aurora music patch
  16. if(Settings.options.enableAuroraTweaks && GameParameterIDs.GetString(rtpcID) == "AURORASTRENGTH")
  17. {
  18. if(rtpcValue > Settings.options.auroraVolume)
  19. {
  20. rtpcValue = Settings.options.auroraVolume;
  21. }
  22. }
  23. // Wind audioc patch
  24. if (Settings.options.enableWindTweaks && GameManager.GetWeatherComponent().IsIndoorScene() && (GameParameterIDs.GetString(rtpcID) == "WINDINTENSITYBLEND"))
  25. {
  26. if (rtpcValue > Settings.options.windVolume)
  27. {
  28. rtpcValue = Settings.options.windVolume;
  29. }
  30. }
  31. if (VolumeIDs.GetRtpcIDMaster() == rtpcID)
  32. {
  33. VolumeMaster.SetMasterVolume(rtpcValue / 100);
  34. }
  35. else if (VolumeIDs.GetRtpcIDList().ContainsKey(rtpcID)) // Set sfx/voice/ambient/bgm
  36. {
  37. VolumeMaster.SetVolume(VolumeIDs.GetRtpcIDList()[rtpcID], rtpcValue / 100);
  38. }
  39. rtpcValue = PatchMaster.ParameterAction(GameParameterIDs.GetString(rtpcID), rtpcValue);
  40. }
  41. }
  42. }