Patch_KylockeStand_Awake.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections;
  3. using GadgetCore.API;
  4. using HarmonyLib;
  5. using UnityEngine;
  6. namespace PlatformBlock.Patches
  7. {
  8. [HarmonyPatch(typeof(KylockeStand))]
  9. [HarmonyPatch("Awake")]
  10. [HarmonyGadget("PlatformBlock")]
  11. public static class Patch_KylockeStand_Awake
  12. {
  13. [HarmonyPrefix]
  14. public static void Prefix(KylockeStand __instance)
  15. {
  16. __instance.StartCoroutine(Patch_KylockeStand_Awake.WaitAndCreate(__instance));
  17. }
  18. private static IEnumerator WaitAndCreate(KylockeStand instance)
  19. {
  20. if (instance.itemID == 2403)
  21. {
  22. while (!Network.isServer && !Network.isClient)
  23. {
  24. yield return new WaitForSeconds(0f);
  25. }
  26. if (Network.isServer)
  27. {
  28. var obj = ((GameObject)Network.Instantiate(Resources.Load("npc/buildStand"), new Vector3(-250f, -5.99f, 0.19f), instance.transform.rotation, 0));
  29. obj.GetComponent<KylockeStand>().GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { new int[] { Core.itemPlatformId, 1000 } });
  30. }
  31. }
  32. yield break;
  33. }
  34. }
  35. }