Patch_KylockeStand_Awake.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using GadgetCore.API;
  2. using GadgetCore.Util;
  3. using HarmonyLib;
  4. using System.Collections;
  5. using UnityEngine;
  6. namespace First.Patches
  7. {
  8. [HarmonyPatch(typeof(KylockeStand))]
  9. [HarmonyPatch("Awake")]
  10. [HarmonyGadget("First")]
  11. public static class Patch_KylockeStand_Awake
  12. {
  13. [HarmonyPostfix]
  14. public static void Prefix(KylockeStand __instance)
  15. {
  16. __instance.StartCoroutine(WaitAMoment(__instance));
  17. }
  18. private static IEnumerator WaitAMoment(KylockeStand instance)
  19. {
  20. if (instance.itemID == 2402)
  21. {
  22. instance.itemID = Core.itemWhiteLampId;
  23. }
  24. else if (instance.itemID == 2401)
  25. {
  26. switch (Random.Range(0, 6))
  27. {
  28. case 0:
  29. instance.itemID = Core.itemYellowLampId;
  30. break;
  31. case 1:
  32. instance.itemID = Core.itemOrangeLampId;
  33. break;
  34. case 2:
  35. instance.itemID = 2401;
  36. break;
  37. case 3:
  38. instance.itemID = Core.itemPurpleLampId;
  39. break;
  40. case 4:
  41. instance.itemID = 2402;
  42. break;
  43. case 5:
  44. instance.itemID = Core.itemGreenLampId;
  45. break;
  46. }
  47. }
  48. yield break;
  49. }
  50. }
  51. }