Browse Source

[ShipDecorations] [2.0.2.1] Use Old Market Stand Generation

Zariteis 4 years ago
parent
commit
26a633ead9

+ 13 - 0
ShipDecorations/Patches/Patch_KylockeStand_Awake.cs

@@ -55,6 +55,19 @@ namespace ShipDecorations.Patches
         CoroutineManager newComponent = instance.gameObject.AddComponent<CoroutineManager>();
         CoroutineManager newComponent = instance.gameObject.AddComponent<CoroutineManager>();
         newComponent.SetAction(new System.Action(() => { newComponent.StartCoroutine(DecpStockUpdateLoop(instance)); }));
         newComponent.SetAction(new System.Action(() => { newComponent.StartCoroutine(DecpStockUpdateLoop(instance)); }));
       }
       }
+      else if (instance.itemID == 2403)
+      {
+        while (!Network.isServer && !Network.isClient)
+        {
+          yield return new WaitForSeconds(0f);
+        }
+        if (Network.isServer)
+        {
+          var obj = ((GameObject)Network.Instantiate(Resources.Load("npc/buildStand"), new Vector3(-250f + 4 * 1, -5.99f, 0.19f), instance.transform.rotation, 0));
+          obj.GetComponent<KylockeStand>().GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { new int[] { Core.itemStoreList[0], 1000 } });
+          obj.GetComponent<KylockeStand>().Awake();
+        }
+      }
       yield break;
       yield break;
     }
     }
 
 

+ 24 - 1
ShipDecorations/Patches/Patch_KylockeStand_Set.cs

@@ -13,7 +13,7 @@ namespace ShipDecorations.Patches
   public static class Patch_KylockeStand_Set
   public static class Patch_KylockeStand_Set
   {
   {
     [HarmonyPostfix]
     [HarmonyPostfix]
-    public static void Prefix(KylockeStand __instance, int[] p)
+    public static bool Prefix(KylockeStand __instance, int[] p)
     {
     {
       if(animate == null)
       if(animate == null)
       {
       {
@@ -30,6 +30,29 @@ namespace ShipDecorations.Patches
         __instance.StartCoroutine(DoUpdateLampAnimation(__instance));
         __instance.StartCoroutine(DoUpdateLampAnimation(__instance));
       if (Core.itemStoreList.Contains(p[0]))
       if (Core.itemStoreList.Contains(p[0]))
         __instance.StartCoroutine(DoUpdateLoadingAnimation(__instance));
         __instance.StartCoroutine(DoUpdateLoadingAnimation(__instance));
+
+      if (p[0] == Core.itemStoreList[0])
+      {
+        __instance.itemID = p[0];
+        __instance.cost = p[1];
+        __instance.icon.GetComponent<Renderer>().material = (Material)Resources.Load("i/i" + __instance.itemID.ToString());
+        __instance.txtCost[0].text = string.Empty + __instance.cost.ToString();
+        __instance.txtCost[1].text = __instance.txtCost[0].text;
+        __instance.txtName[0].text = string.Empty + ItemRegistry.GetItem(__instance.itemID).GetName();
+        __instance.txtName[1].text = __instance.txtName[0].text;
+        __instance.StartCoroutine(Patch_KylockeStand_Set.DoUpdatePlatformStand(__instance));
+        return false;
+      }
+      return true;
+    }
+
+    private static IEnumerator DoUpdatePlatformStand(KylockeStand instance)
+    {
+      instance.isBuild = true;
+      instance.isCredits = false;
+      instance.isTrophies = false;
+      instance.currency.GetComponent<Renderer>().material = (Material)Resources.Load("i/i57");
+      yield break;
     }
     }
 
 
     private static bool? animate = null;
     private static bool? animate = null;

+ 11 - 9
ShipDecorations/ShipDecorations.cs

@@ -3,6 +3,7 @@ using GadgetCore.API;
 using UnityEngine.SceneManagement;
 using UnityEngine.SceneManagement;
 using System.Reflection;
 using System.Reflection;
 using GadgetCore.API.ConfigMenu;
 using GadgetCore.API.ConfigMenu;
+using System;
 
 
 namespace ShipDecorations
 namespace ShipDecorations
 {
 {
@@ -13,6 +14,7 @@ namespace ShipDecorations
     public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
     public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
 
 
     public override IGadgetConfigMenu GetConfigMenu() { return null; }
     public override IGadgetConfigMenu GetConfigMenu() { return null; }
+    protected override void LoadConfig() { Config.Reset(); Config.Save(); }
 
 
     public override string GetModDescription()
     public override string GetModDescription()
     {
     {
@@ -30,24 +32,24 @@ namespace ShipDecorations
       AddToList(ItemUtil.CreatePlacableDecoItem("cTreantHeadPlant.png", "iTreantHeadPlant.png", "Treant Plant"), 10000);
       AddToList(ItemUtil.CreatePlacableDecoItem("cTreantHeadPlant.png", "iTreantHeadPlant.png", "Treant Plant"), 10000);
       AddToList(ItemUtil.CreatePlacableSlideDoorItem("cDoor.png", "cDoorOpen.png", "iDoor.png", "Door"), 5000);
       AddToList(ItemUtil.CreatePlacableSlideDoorItem("cDoor.png", "cDoorOpen.png", "iDoor.png", "Door"), 5000);
 
 
-      SceneManager.sceneLoaded += OnSceneLoaded;
+      // SceneManager.sceneLoaded += OnSceneLoaded;
     }
     }
 
 
     internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
     internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
     {
     {
       if (scene.buildIndex == 1)
       if (scene.buildIndex == 1)
       {
       {
-        var i = GadgetCoreAPI.CreateMarketStand(ItemRegistry.GetItem(Core.itemStoreList[0]), new Vector2(-138f - 2 * 4, -7.49f), 1000);
-        call(i.GetComponent<KylockeStand>(), "Awake");
+        try
+        {
+          // GameObject obj = GadgetCoreAPI.CreateMarketStand(ItemRegistry.GetItem(Core.itemStoreList[0]), new Vector2(-138f - 2 * 4, -7.49f), 100);
+          // // NetworkView network = obj.GetComponent<NetworkView>();
+          // // network.viewID = NetworkViewID.unassigned;
+          // // obj.GetComponent<KylockeStand>().Awake();
+        }
+        catch (Exception e) { Core.logger.LogConsole(e.Message); }
       }
       }
     }
     }
 
 
-    private static object call<T>(T __instance, string meth, object[] o = null)
-    {
-      MethodInfo dynMethod = __instance.GetType().GetMethod(meth, BindingFlags.NonPublic | BindingFlags.Instance);
-      return dynMethod.Invoke(__instance, o ?? new object[0]);
-    }
-
     private void AddToList(int id, int price)
     private void AddToList(int id, int price)
     {
     {
       Core.itemStoreList.Add(id);
       Core.itemStoreList.Add(id);