VolumePatches.cs 748 B

12345678910111213141516171819202122
  1. using Il2Cpp;
  2. using UnityEngine;
  3. namespace AudioMgr
  4. {
  5. [HarmonyLib.HarmonyPatch(typeof(GameAudioManager), "SetRTPCValue")]
  6. public class VolumeChanged
  7. {
  8. public static void Prefix(ref GameAudioManager __instance, ref uint rtpcID, ref float rtpcValue, ref GameObject go)
  9. {
  10. if (VolumeIDs.GetRtpcIDMaster() == rtpcID)
  11. {
  12. VolumeMaster.SetMasterVolume(rtpcValue/100);
  13. }
  14. else if (VolumeIDs.GetRtpcIDList().ContainsKey(rtpcID)) // Set sfx/voice/ambient/bgm
  15. {
  16. VolumeMaster.SetVolume(VolumeIDs.GetRtpcIDList()[rtpcID], rtpcValue/100);
  17. }
  18. }
  19. }
  20. }