using GadgetCore.API; using GadgetCore.Util; using HarmonyLib; using System.Collections; using System.Threading; using System.Windows.Threading; using UnityEngine; namespace Ships.Patches { [HarmonyPatch(typeof(Chunk))] [HarmonyPatch("SpawnBiomeSlot")] [HarmonyGadget("Ships")] public static class Patch_Chunk_SpawnBiomeSlot { [HarmonyPostfix] public static bool Prefix(Chunk __instance, int a, int i, int mid, ref GameObject[] ___spawnSpot, ref GameObject[] ___spawnSpotMid, ref GameObject[] ___networkStuff, ref int ___temp) { Transform transform; if (mid == 1) transform = ___spawnSpotMid[i].transform; else transform = ___spawnSpot[i].transform; int num = UnityEngine.Random.Range(0, 100); if (num < 3 && !Core.shipPorterPlaced) { Core.shipPorterPlaced = true; if (a == 0 || a == 1 || a == 2 || a == 3 || a == 4 || a == 5) { var portal = (GameObject)Network.Instantiate((GameObject)Resources.Load("portal"), transform.position + new Vector3(0, 1.5f - 0.05f, 0.2f), Quaternion.identity, 0); portal.name = "portal/5/obj"; var iUA = portal.transform.GetChild(0).gameObject; portal.GetComponent().RPC("Activate", RPCMode.All, new object[0]); iUA.GetComponent().RPC("Set", RPCMode.AllBuffered, new object[] { Core.shipPlanet.GetID(), 0, 5 }); ___networkStuff[___temp] = portal; ___temp++; var crates = (GameObject)Network.Instantiate(Resources.Load("obj/Ships/BrokenCrates1"), transform.position + new Vector3(2, 0, 0.2f), Quaternion.identity, 0); ___networkStuff[___temp] = crates; ___temp++; return false; } } return true; } } }