Quellcode durchsuchen

[CombatChipChest] [2.0.3.6] ScrapYard.API link

Zariteis vor 4 Jahren
Ursprung
Commit
8b0538de89

+ 4 - 16
CombatChipChest/CombatChipChest.cs

@@ -1,15 +1,16 @@
 using GadgetCore.API;
 using GadgetCore.API.ConfigMenu;
+using ScrapYard.API;
 using System;
 using UnityEngine;
 using UnityEngine.SceneManagement;
 
 namespace CombatChipChest
 {
-  [Gadget("CombatChipChest")]
+  [Gadget("CombatChipChest", LoadAfter: new string[] { "ScrapYard" }, Dependencies: new string[] { "ScrapYard" })]
   public class CombatChipChest : Gadget<CombatChipChest>
   {
-    public const string MOD_VERSION = "1.0"; // Set this to the version of your mod.
+    public const string MOD_VERSION = "1.1"; // Set this to the version of your mod.
     public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.
 
     public override IGadgetConfigMenu GetConfigMenu() { return null; }
@@ -40,21 +41,8 @@ namespace CombatChipChest
       Core.menu = new MenuInfo(MenuType.CHIP, menuCombat, tile);
       Core.menu.Register("Combat Chip Chest");
 
-      // SceneManager.sceneLoaded += OnSceneLoaded;
-    }
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(Core.itemCombatChipChestId, 1000));
 
-    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
-    {
-      if (scene.buildIndex == 1)
-      {
-        try
-        {
-          // GameObject obj = GadgetCoreAPI.CreateMarketStand(ItemRegistry.GetItem(Core.itemCombatChipChestId), new Vector2(-138f - 1 * 4, -7.49f), 100);
-          // // NetworkView network = obj.GetComponent<NetworkView>();
-          // // network.viewID = Network.AllocateViewID();
-        }
-        catch (Exception e) { Core.logger.LogConsole(e.Message); }
-      }
     }
   }
 }

+ 5 - 0
CombatChipChest/CombatChipChest.csproj

@@ -46,6 +46,11 @@
       <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
       <Private>false</Private>
     </Reference>
+    <Reference Include="ScrapYard">
+      <HintPath>..\ScrapYard\Release\ScrapYard.dll</HintPath>
+      <Private>false</Private>
+      <SpecificVersion>false</SpecificVersion>
+    </Reference>
     <Reference Include="UnityEngine">
       <HintPath>$(GamePath)$(ManagedFolder)UnityEngine.dll</HintPath>
       <Private>false</Private>

+ 2 - 1
CombatChipChest/Manifest.ini

@@ -1,3 +1,4 @@
 [Metadata]
 Name=Combat Chip Chest
-Assembly=CombatChipChest.dll
+Assembly=CombatChipChest.dll
+Dependencies=Scrap Yard

+ 0 - 37
CombatChipChest/Patches/Patch_KylockeStand_Awake.cs

@@ -1,37 +0,0 @@
-using System;
-using System.Collections;
-using GadgetCore.API;
-using HarmonyLib;
-using UnityEngine;
-
-namespace CombatChipChest.Patches
-{
-  [HarmonyPatch(typeof(KylockeStand))]
-  [HarmonyPatch("Awake")]
-  [HarmonyGadget("CombatChipChest")]
-  public static class Patch_KylockeStand_Awake
-  {
-    [HarmonyPrefix]
-    public static void Prefix(KylockeStand __instance)
-    {
-      __instance.StartCoroutine(Patch_KylockeStand_Awake.WaitAndCreate(__instance));
-    }
-
-    private static IEnumerator WaitAndCreate(KylockeStand instance)
-    {
-      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 + 8, -5.99f, 0.19f), instance.transform.rotation, 0));
-          obj.GetComponent<KylockeStand>().GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { new int[] { Core.itemCombatChipChestId, 1000 } });
-        }
-      }
-      yield break;
-    }
-  }
-}

+ 0 - 42
CombatChipChest/Patches/Patch_KylockeStand_Set.cs

@@ -1,42 +0,0 @@
-using System;
-using System.Collections;
-using GadgetCore.API;
-using HarmonyLib;
-using UnityEngine;
-
-namespace CombatChipChest.Patches
-{
-	[HarmonyPatch(typeof(KylockeStand))]
-	[HarmonyPatch("Set")]
-	[HarmonyGadget("CombatChipChest")]
-	public static class Patch_KylockeStand_Set
-	{
-
-		[HarmonyPostfix]
-		public static bool Prefix(KylockeStand __instance, int[] p)
-		{
-			if (p[0] == Core.itemCombatChipChestId)
-			{
-				__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;
-		}
-	}
-}