Browse Source

[ScrapYard] [2.0.3.6] remove default shop stands

Zariteis 4 years ago
parent
commit
3faddf63da

+ 1 - 5
ScrapYard/API/ShopPlatform.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using UnityEngine;
+using System.Collections.Generic;
 
 namespace ScrapYard.API
 {

+ 1 - 7
ScrapYard/API/ShopPlatformEntry.cs

@@ -1,10 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using UnityEngine;
-
-namespace ScrapYard.API
+namespace ScrapYard.API
 {
   public class ShopPlatformEntry
   {

+ 0 - 5
ScrapYard/Core.cs

@@ -1,9 +1,4 @@
 using GadgetCore;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using UnityEngine;
 
 namespace ScrapYard
 {

+ 30 - 0
ScrapYard/Patches/Patch_KylockeStand_Awake.cs

@@ -0,0 +1,30 @@
+using GadgetCore.API;
+using HarmonyLib;
+using System.Collections;
+using UnityEngine;
+
+namespace ScrapYard.Patches
+{
+
+  [HarmonyPatch(typeof(KylockeStand))]
+  [HarmonyPatch("Awake")]
+  [HarmonyGadget("ScrapYard")]
+  public static class Patch_KylockeStand_Awake
+  {
+    [HarmonyPostfix]
+    public static void Postfix(KylockeStand __instance)
+    {
+      __instance.StartCoroutine(Deactivate(__instance));
+    }
+
+    private static IEnumerator Deactivate(KylockeStand instance)
+    {
+      yield return new WaitForSeconds(2f);
+      if (instance.itemID >= 2000 && instance.itemID < 2500 || instance.itemID == ItemRegistry.GetItemIDByRegistryName("Gadget Core:Crafter Block"))
+      {
+        instance.gameObject.SetActive(false);
+      }
+      yield break;
+    }
+  }
+}

+ 17 - 3
ScrapYard/ScrapYard.cs

@@ -1,9 +1,9 @@
-using UnityEngine;
 using GadgetCore.API;
-using System.Collections.Generic;
 using ScrapYard.API;
 using System.Collections;
 using System.Reflection;
+using UnityEngine;
+using UnityEngine.SceneManagement;
 
 namespace ScrapYard
 {
@@ -70,7 +70,7 @@ namespace ScrapYard
       scrapYardPlanet.OnGenerateWorld += ScrapYardGenerator.GenarateTown;
       scrapYardPlanet.Register("Scrap Yard");
 
-      new ItemInfo(ItemType.GENERIC, "Scrap Trophy", "", textureScrapTrophy).Register("Scrap Trophy");
+      new ItemInfo(ItemType.GENERIC, "Scrap Trophy", "A rusty trophy.\nUsed for purchasing\nspecial items.", textureScrapTrophy).Register("Scrap Trophy");
 
       { // Scrap Yard Bulding
         var scrapYardShopBuilding = Object.Instantiate((GameObject)Resources.Load("prop/2501"));
@@ -266,11 +266,25 @@ namespace ScrapYard
       ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2107, 10));
       ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2108, 10));
       ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2403, 10));
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(ItemRegistry.GetItemIDByRegistryName("Gadget Core:Crafter Block"), 10));
       ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2401, 1000));
       ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(2402, 1000));
 
       ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(2200, 50));
 
+      SceneManager.sceneLoaded += OnSceneLoaded;
+    }
+
+    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
+    {
+      if (scene.buildIndex == 1)
+      {
+        try
+        {
+          var storageMenu = GameObject.Find("Ship").transform.Find("SHIPPLACES").transform.Find("mech").localPosition = new Vector3(-130f, -5.23f, 0.6f);
+        }
+        catch (System.Exception e) { Core.logger.LogError(e.Message); }
+      }
     }
 
     public static readonly FieldInfo canInteractField = typeof(PlayerScript).GetField("canInteract", BindingFlags.NonPublic | BindingFlags.Instance);

+ 3 - 9
ScrapYard/ScrapYardGenerator.cs

@@ -1,10 +1,8 @@
 using GadgetCore.API;
 using ScrapYard.API;
 using System;
-using System.Collections.Generic;
 using System.Reflection;
 using UnityEngine;
-using Random = System.Random;
 
 namespace ScrapYard
 {
@@ -67,11 +65,7 @@ namespace ScrapYard
 
     public static void PopulateTown(Chunk chunk)
     {
-      var networkStuff = (GameObject[])networkStuffField.GetValue(chunk);
-
-      GameObject[] newNetworkStuff = new GameObject[40];
-      Array.Copy(networkStuff, newNetworkStuff, networkStuff.Length);
-      networkStuff = newNetworkStuff;
+      var networkStuff = new GameObject[40];
       networkStuffField.SetValue(chunk, networkStuff);
 
       try
@@ -109,10 +103,10 @@ namespace ScrapYard
           }
         }
         networkStuff[temp] = (GameObject)Network.Instantiate((GameObject)Resources.Load("prop/ScrapYard/stand"), new Vector3(268.5f, -6.1175f - 1.45f, 0.2f), Quaternion.identity, 0);
-        networkStuff[temp].GetComponent<ScrapYardShopStandScript>().StartCallSet(ItemRegistry.GetItemIDByName("Scrap Trophy"), 9999, 1, 57);
+        networkStuff[temp].GetComponent<ScrapYardShopStandScript>().StartCallSet(ItemRegistry.GetItemIDByRegistryName("ScrapYard:Scrap Trophy"), 9999, 1, 57);
         temp++;
         networkStuff[temp] = (GameObject)Network.Instantiate((GameObject)Resources.Load("prop/ScrapYard/stand"), new Vector3(272.5f, -6.1175f - 1.45f, 0.2f), Quaternion.identity, 0);
-        networkStuff[temp].GetComponent<ScrapYardShopStandScript>().StartCallSet(57, 1, 9999, ItemRegistry.GetItemIDByName("Scrap Trophy"));
+        networkStuff[temp].GetComponent<ScrapYardShopStandScript>().StartCallSet(57, 1, 9999, ItemRegistry.GetItemIDByRegistryName("ScrapYard:Scrap Trophy"));
         temp++;
       }
       catch (Exception e) { Core.logger.LogError(e); }