Patch_Chunk_SpawnBiomeSlot.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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, 700);
  24. if (num < 5)
  25. {
  26. if (a == 0)
  27. {
  28. if (Random.Range(0, 2) == 0)
  29. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectBugTree.Object, transform.position, Quaternion.identity, 0);
  30. else
  31. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectBugspotBig.Object, transform.position, Quaternion.identity, 0);
  32. ___temp++;
  33. return false;
  34. }
  35. else if (a == 1)
  36. {
  37. if (GameScript.challengeLevel <= 0)
  38. ___networkStuff[___temp] = (GameObject)Network.Instantiate((GameObject)Resources.Load(Core.objectSpikePlant.ResourcePath), transform.position, Quaternion.identity, 0);
  39. else
  40. ___networkStuff[___temp] = (GameObject)Network.Instantiate((GameObject)Resources.Load(Core.objectSpikePlantCM.ResourcePath), transform.position, Quaternion.identity, 0);
  41. ___temp++;
  42. return false;
  43. }
  44. else if (a == 2)
  45. {
  46. if (GameScript.challengeLevel <= 0)
  47. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectSpiderEgg.Object, transform.position, Quaternion.identity, 0);
  48. else
  49. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectSpiderEggCM.Object, transform.position, Quaternion.identity, 0);
  50. ___temp++;
  51. return false;
  52. }
  53. else if (a == 3)
  54. {
  55. if (Random.Range(0, 2) == 0)
  56. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectGoldenShroom.Object, transform.position, Quaternion.identity, 0);
  57. else
  58. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectWizShroom.Object, transform.position, Quaternion.identity, 0);
  59. ___temp++;
  60. return false;
  61. }
  62. else if (a == 4)
  63. {
  64. if (GameScript.challengeLevel <= 0)
  65. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectAncientCrystal.Object, transform.position, Quaternion.identity, 0);
  66. else
  67. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectAncientCrystalCM.Object, transform.position, Quaternion.identity, 0);
  68. ___temp++;
  69. return false;
  70. }
  71. //else if (a == 5)
  72. //{
  73. // ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectPlagueNest.Object, transform.position, Quaternion.identity, 0);
  74. // ___temp++;
  75. // return false;
  76. //}
  77. else if (a == 6)
  78. {
  79. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectFrozenWisp.Object, transform.position, Quaternion.identity, 0);
  80. ___temp++;
  81. return false;
  82. }
  83. else if (a == 7)
  84. {
  85. ___networkStuff[___temp] = (GameObject)Network.Instantiate(Core.objectMolten.Object, transform.position, Quaternion.identity, 0);
  86. ___temp++;
  87. return false;
  88. }
  89. }
  90. return true;
  91. }
  92. }
  93. }