Patch_SpawnerScript_DestroyWorld.cs 795 B

123456789101112131415161718192021222324252627282930
  1. using GadgetCore.API;
  2. using HarmonyLib;
  3. using System;
  4. using System.Collections;
  5. using UnityEngine;
  6. namespace LoopPortal.Patches
  7. {
  8. [HarmonyPatch(typeof(SpawnerScript))]
  9. [HarmonyPatch("DestroyWorld")]
  10. [HarmonyGadget("LoopPortal")]
  11. public static class Patch_SpawnerScript_DestroyWorld
  12. {
  13. [HarmonyPrefix]
  14. public static void Prefix(SpawnerScript __instance, int a)
  15. {
  16. if (Network.isServer)
  17. {
  18. GameObject gameObject = Core.portalObject;
  19. if (gameObject != null)
  20. {
  21. Network.RemoveRPCs(gameObject.GetComponent<NetworkView>().viewID);
  22. Network.RemoveRPCs(gameObject.transform.GetChild(0).gameObject.gameObject.GetComponent<NetworkView>().viewID);
  23. Network.Destroy(gameObject.gameObject);
  24. }
  25. }
  26. }
  27. }
  28. }