Patch_Chunk_SpawnBiomeSlot.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using GadgetCore.API;
  2. using GadgetCore.Util;
  3. using HarmonyLib;
  4. using System.Collections;
  5. using System.Threading;
  6. using System.Windows.Threading;
  7. using UnityEngine;
  8. namespace MonsterNests.Patches
  9. {
  10. [HarmonyPatch(typeof(Chunk))]
  11. [HarmonyPatch("SpawnBiomeSlot")]
  12. [HarmonyGadget("MonsterNests")]
  13. public static class Patch_Chunk_SpawnBiomeSlot
  14. {
  15. [HarmonyPostfix]
  16. public static bool Prefix(Chunk __instance, int a, int i, int mid, ref GameObject[] ___spawnSpot, ref GameObject[] ___spawnSpotMid, ref GameObject[] ___networkStuff, ref int ___temp)
  17. {
  18. Transform transform;
  19. if (mid == 1)
  20. transform = ___spawnSpotMid[i].transform;
  21. else
  22. transform = ___spawnSpot[i].transform;
  23. int num = UnityEngine.Random.Range(0, 100);
  24. if (num < 2)
  25. {
  26. if (a == 0)
  27. {
  28. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectBugspotBig.Object, transform.position, Quaternion.identity, 0);
  29. ___temp++;
  30. return false;
  31. }
  32. if (a == 2)
  33. {
  34. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectSpiderEgg.Object, transform.position, Quaternion.identity, 0);
  35. ___temp++;
  36. return false;
  37. }
  38. if (a == 3)
  39. {
  40. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectGoldenShroom.Object, transform.position, Quaternion.identity, 0);
  41. ___temp++;
  42. return false;
  43. }
  44. }
  45. return true;
  46. }
  47. }
  48. }