| 12345678910111213141516171819202122232425262728293031323334 |
- using GadgetCore.API;
- using HarmonyLib;
- using UnityEngine;
- namespace Ships.Patches
- {
- [HarmonyPatch(typeof(Chunk))]
- [HarmonyPatch("OnDestroy")]
- [HarmonyGadget("Ships")]
- public static class Patch_Chunk_OnDestroyy
- {
- [HarmonyPrefix]
- [HarmonyPriority(1010)]
- public static void Prefix(Chunk __instance, ref GameObject[] ___networkStuff)
- {
- Core.shipPorterPlaced = false;
- if (___networkStuff.Length > 40)
- {
- if (Network.isServer)
- {
- for (int i = 0; i < ___networkStuff.Length; i++)
- {
- if (___networkStuff[i])
- {
- Network.RemoveRPCs(___networkStuff[i].GetComponent<NetworkView>().viewID);
- Network.Destroy(___networkStuff[i].gameObject);
- }
- }
- }
- ___networkStuff = new GameObject[40];
- }
- }
- }
- }
|