Browse Source

[2.0.3.9] Meteors and Space Jelly added to meteor generation

Zariteis 4 years ago
parent
commit
7fd54ce335

BIN
Assets/Meteoroid/spaceOreBig.png


+ 2 - 0
Core.cs

@@ -25,5 +25,7 @@ namespace Subworlds
     public static ItemInfo itemOldTexMod;
 
     public static int lastBiome = -1;
+
+    public static bool planetHasMeteors = false;
   }
 }

+ 28 - 0
Generator/MeteroidGenerator.cs

@@ -101,6 +101,7 @@ namespace Subworlds
           chunks[num] = new GameObject("chunk");
           var chunk = chunks[num].AddComponent<Chunk>();
           PopulateWorld(chunk);
+          chunk.StartCoroutine(Meteors());
           num++;
         }
       }
@@ -277,6 +278,10 @@ namespace Subworlds
                 var position = new Vector3((float)(242 + x * 4 - 60), y * 4 - 60 + GetSizeForPixels(54) + 1.049f, 0f);
 
                 if (random.Next(2) == 0)
+                {
+                  Network.Instantiate(Resources.Load("e/Subworlds/Jelly"), position, Quaternion.identity, 0);
+                }
+                else if (random.Next(2) == 0)
                 {
                   networkStuff[temp] = (GameObject)Network.Instantiate(Resources.Load("obj/Subworlds/SpaceOre1"), position, Quaternion.identity, 0);
                   temp++;
@@ -307,5 +312,28 @@ namespace Subworlds
         }
       }
     }
+
+    private static IEnumerator Meteors()
+    {
+      yield return new WaitForSeconds((float)UnityEngine.Random.Range(1, 5));
+      if (Network.isServer && MenuScript.player != null)
+      {
+        while (true)
+        {
+          if (GameScript.isTown || !GameScript.inInstance)
+            break;
+          Vector3 spawnPos = new Vector3(MenuScript.player.transform.position.x + (float)UnityEngine.Random.Range(-20, 70), MenuScript.player.transform.position.y + 40f, 0f);
+          GameObject p;
+          if (UnityEngine.Random.Range(0, 3) == 0)
+            p = (GameObject)Network.Instantiate(Resources.Load("proj/meteor"), spawnPos, Quaternion.identity, 0);
+          else
+            p = (GameObject)Network.Instantiate(Resources.Load("proj/meteor2"), spawnPos, Quaternion.identity, 0);
+          Vector3 target = new Vector3(MenuScript.player.transform.position.x + (float)UnityEngine.Random.Range(-20, 70), MenuScript.player.transform.position.y, 0f);
+          p.SendMessage("EnemySet", target, SendMessageOptions.DontRequireReceiver);
+          yield return new WaitForSeconds(1f);
+        }
+      }
+      yield break;
+    }
   }
 }

+ 3 - 3
Patches/Patch_Chunk_SpawnBiomeSlot.cs

@@ -24,7 +24,7 @@ namespace Subworlds.Patches
         transform = ___spawnSpot[i].transform;
 
       int num = UnityEngine.Random.Range(0, 100);
-      if (num < 3 && !Core.shipPorterPlaced)
+      if (num < 30 && !Core.shipPorterPlaced)
       {
         Core.shipPorterPlaced = true;
         if (a == 0 || a == 1 || a == 2 || a == 3 || a == 4 || a == 5)
@@ -42,7 +42,7 @@ namespace Subworlds.Patches
           return false;
         }
       }
-      if (num < 4 && Core.shipPorterPlaced && !Core.meteorPorterPlaced)
+      if (num < 50 && !Core.meteorPorterPlaced && Core.planetHasMeteors)
       {
         Core.meteorPorterPlaced = true;
         if (a == 0 || a == 1 || a == 2 || a == 3 || a == 4 || a == 5)
@@ -54,7 +54,7 @@ namespace Subworlds.Patches
           iUA.GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { Core.meteroidPlanet.GetID(), 0, 6 });
           ___networkStuff[___temp] = portal;
           ___temp++;
-          var crates = (GameObject)Network.Instantiate(Resources.Load("obj/Subworlds/BrokenMeteor"), transform.position + new Vector3(-1.5f, 0 + 2.03f, 0.2f), Quaternion.identity, 0);
+          var crates = (GameObject)Network.Instantiate(Resources.Load("obj/Subworlds/BrokenMeteor"), transform.position + new Vector3(-1.5f, 0 + 2.02f, 0.2f), Quaternion.identity, 0);
           ___networkStuff[___temp] = crates;
           ___temp++;
           return false;

+ 17 - 0
Patches/Patch_GameScript_Meteors.cs

@@ -0,0 +1,17 @@
+using GadgetCore.API;
+using HarmonyLib;
+
+namespace Subworlds.Patches
+{
+  [HarmonyPatch(typeof(GameScript))]
+  [HarmonyPatch("Meteors")]
+  [HarmonyGadget("SubworldCore")]
+  public static class Patch_GameScript_Meteors
+  {
+    [HarmonyPrefix]
+    public static void Prefix(GameScript __instance)
+    {
+      Core.planetHasMeteors = true;
+    }
+  }
+}

+ 0 - 3
Patches/Patch_ObjectScript_Die.cs

@@ -1,9 +1,6 @@
 using GadgetCore.API;
-using GadgetCore.Util;
 using HarmonyLib;
 using System.Collections;
-using System.Threading;
-using System.Windows.Threading;
 using UnityEngine;
 
 namespace Subworlds.Patches