| 123456789101112131415161718192021222324252627282930313233 |
- using GadgetCore.API;
- using HarmonyLib;
- using UnityEngine;
- namespace ScrapYard.Patches
- {
- [HarmonyPatch(typeof(Chunk))]
- [HarmonyPatch("OnDestroy")]
- [HarmonyGadget("ScrapYard")]
- public static class Patch_Chunk_OnDestroyy
- {
- [HarmonyPrefix]
- [HarmonyPriority(1010)]
- public static void Prefix(Chunk __instance, ref GameObject[] ___networkStuff)
- {
- 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];
- }
- }
- }
- }
|