Browse Source

[PlatformBlock] [2.0.3.6] ScrapYard.API port

Zariteis 4 years ago
parent
commit
fb0907518e

+ 0 - 5
PlatformBlock/Core.cs

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

+ 2 - 2
PlatformBlock/ItemUtil.cs

@@ -1,5 +1,5 @@
-using UnityEngine;
-using GadgetCore.API;
+using GadgetCore.API;
+using UnityEngine;
 
 
 namespace PlatformBlock
 namespace PlatformBlock
 {
 {

+ 0 - 37
PlatformBlock/Patches/Patch_KylockeStand_Awake.cs

@@ -1,37 +0,0 @@
-using System;
-using System.Collections;
-using GadgetCore.API;
-using HarmonyLib;
-using UnityEngine;
-
-namespace PlatformBlock.Patches
-{
-  [HarmonyPatch(typeof(KylockeStand))]
-  [HarmonyPatch("Awake")]
-  [HarmonyGadget("PlatformBlock")]
-  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, -5.99f, 0.19f), instance.transform.rotation, 0));
-          obj.GetComponent<KylockeStand>().GetComponent<NetworkView>().RPC("Set", RPCMode.AllBuffered, new object[] { new int[] { Core.itemPlatformId, 1000 } });
-        }
-      }
-      yield break;
-    }
-  }
-}

+ 0 - 42
PlatformBlock/Patches/Patch_KylockeStand_Set.cs

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

+ 4 - 13
PlatformBlock/PlatformBlock.cs

@@ -1,14 +1,13 @@
-using UnityEngine;
 using GadgetCore.API;
 using GadgetCore.API;
-using UnityEngine.SceneManagement;
 using GadgetCore.API.ConfigMenu;
 using GadgetCore.API.ConfigMenu;
+using ScrapYard.API;
 
 
 namespace PlatformBlock
 namespace PlatformBlock
 {
 {
-  [Gadget("PlatformBlock")]
+  [Gadget("PlatformBlock", LoadAfter: new string[] { "ScrapYard" }, Dependencies: new string[] { "ScrapYard" })]
   public class PlatformBlock : Gadget<PlatformBlock>
   public class PlatformBlock : Gadget<PlatformBlock>
   {
   {
-    public const string MOD_VERSION = "1.1"; // Set this to the version of your mod.
+    public const string MOD_VERSION = "1.2"; // 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 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; }
@@ -25,15 +24,7 @@ namespace PlatformBlock
 
 
       Core.itemPlatformId = ItemUtil.CreatePlacablePlatformItem("cPlatform.png", "iPlatform.png", "Platform Block");
       Core.itemPlatformId = ItemUtil.CreatePlacablePlatformItem("cPlatform.png", "iPlatform.png", "Platform Block");
 
 
-      // SceneManager.sceneLoaded += OnSceneLoaded;
-    }
-
-    internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
-    {
-      if (scene.buildIndex == 1)
-      {
-        // GadgetCoreAPI.CreateMarketStand(ItemRegistry.GetItem(Core.itemPlatformId), new Vector2(-138f - 3 * 4, -7.49f), 500);
-      }
+      ShopPlatform.DefaultBlocks.AddShopPlatformEntry(new ShopPlatformEntry(Core.itemPlatformId, 300));
     }
     }
   }
   }
 }
 }

+ 8 - 0
PlatformBlock/PlatformBlock.csproj

@@ -46,6 +46,11 @@
       <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
       <HintPath>$(GamePath)$(ManagedFolder)GadgetCore.dll</HintPath>
       <Private>false</Private>
       <Private>false</Private>
     </Reference>
     </Reference>
+    <Reference Include="ScrapYard">
+      <HintPath>..\ScrapYard\Release\ScrapYard.dll</HintPath>
+      <Private>false</Private>
+      <SpecificVersion>false</SpecificVersion>
+    </Reference>
     <Reference Include="UnityEngine">
     <Reference Include="UnityEngine">
       <HintPath>$(GamePath)$(ManagedFolder)UnityEngine.dll</HintPath>
       <HintPath>$(GamePath)$(ManagedFolder)UnityEngine.dll</HintPath>
       <Private>false</Private>
       <Private>false</Private>
@@ -200,4 +205,7 @@
       <EmbedInteropTypes>false</EmbedInteropTypes>
       <EmbedInteropTypes>false</EmbedInteropTypes>
     </Reference>
     </Reference>
   </ItemGroup>
   </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Patches\" />
+  </ItemGroup>
 </Project>
 </Project>

+ 1 - 3
PlatformBlock/PlatformColliderScript.cs

@@ -1,6 +1,4 @@
-
-using System;
-using UnityEngine;
+using UnityEngine;
 
 
 namespace PlatformBlock
 namespace PlatformBlock
 {
 {

+ 1 - 3
PlatformBlock/PlatformOnTopScript.cs

@@ -1,6 +1,4 @@
-
-using System;
-using UnityEngine;
+using UnityEngine;
 
 
 namespace PlatformBlock
 namespace PlatformBlock
 {
 {