1
0

AuroraPatches.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Il2Cpp;
  2. using MelonLoader;
  3. using UnityEngine;
  4. namespace AudioMgr
  5. {
  6. [HarmonyLib.HarmonyPatch(typeof(AuroraActivatedToggle), "SetState", new Type[] { typeof(AuroraActivatedToggleState) })]
  7. public class TurnOnPatch
  8. {
  9. public static void Prefix(ref AuroraActivatedToggle __instance, ref AuroraActivatedToggleState state)
  10. {
  11. if (Settings.options.customRadioMusic)
  12. {
  13. if (__instance.m_ToggleOffAudio == "Stop_RadioAurora" && state == AuroraActivatedToggleState.On)
  14. {
  15. if (Settings.options.radioWorksWithoutAurora)
  16. {
  17. __instance.m_RequiresAuroraField = false;
  18. for (int i = 0; i < __instance.transform.childCount; i++)
  19. {
  20. __instance.transform.GetChild(i).gameObject.SetActive(true);
  21. }
  22. __instance.m_ChildrenEnabled = true;
  23. //__instance.UpdateChildStatus(true);
  24. MelonLogger.Msg("StartPlay");
  25. RadioMaster.StartPlay(__instance.gameObject);
  26. }
  27. }
  28. if (__instance.m_ToggleOffAudio == "Stop_RadioAurora" && state == AuroraActivatedToggleState.Off)
  29. {
  30. if (Settings.options.radioWorksWithoutAurora)
  31. {
  32. MelonLogger.Msg("StopPlay");
  33. RadioMaster.StopPlay(__instance.gameObject);
  34. }
  35. }
  36. }
  37. }
  38. }
  39. [HarmonyLib.HarmonyPatch(typeof(AuroraActivatedToggle), "Update")]
  40. public class LightingPatch
  41. {
  42. public static bool Prefix(ref AuroraActivatedToggle __instance)
  43. {
  44. if (Settings.options.customRadioMusic && Settings.options.radioWorksWithoutAurora)
  45. {
  46. __instance.m_RequiresAuroraField = false;
  47. return false;
  48. }
  49. return true;
  50. }
  51. }
  52. [HarmonyLib.HarmonyPatch(typeof(AuroraActivatedToggle), "ShouldEnableChildren")]
  53. public class ShouldEnableEffectPatch
  54. {
  55. public static void Postfix(ref AuroraActivatedToggle __instance, ref bool __result)
  56. {
  57. if (Settings.options.customRadioMusic && Settings.options.radioWorksWithoutAurora)
  58. {
  59. __result = true;
  60. }
  61. }
  62. }
  63. }