Quellcode durchsuchen

[MultiplayerClientSpawn] [2.0.3.6] ScrapYard.API and cleanup

Zariteis vor 4 Jahren
Ursprung
Commit
2a7d176060

BIN
MultiplayerClientSpawn/Assets/stand0.png


BIN
MultiplayerClientSpawn/Assets/stand1.png


BIN
MultiplayerClientSpawn/Assets/stand2.png


BIN
MultiplayerClientSpawn/Assets/stand3.png


BIN
MultiplayerClientSpawn/Assets/stand4.png


BIN
MultiplayerClientSpawn/Assets/stand5.png


BIN
MultiplayerClientSpawn/Assets/stand6.png


+ 1 - 5
MultiplayerClientSpawn/Core.cs

@@ -1,15 +1,11 @@
 using GadgetCore;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using UnityEngine;
 
 namespace MultiplayerClientSpawn
 {
   internal static class Core
   {
     public static int itemSpawnId = -1;
+    public static int itemSpawn2Id = -1;
 
     public static GadgetLogger logger;
   }

+ 0 - 27
MultiplayerClientSpawn/CoroutineManager.cs

@@ -1,27 +0,0 @@
-using GadgetCore.API;
-using GadgetCore.Util;
-using HarmonyLib;
-using System;
-using System.Collections;
-using System.Threading;
-using System.Windows.Threading;
-using UnityEngine;
-
-namespace MultiplayerClientSpawn
-{
-  public class CoroutineManager : MonoBehaviour
-  {
-    Action action;
-
-    public void SetAction(Action action)
-    {
-      this.action = action;
-    }
-
-    void OnEnable()
-    {
-      if (action != null)
-        action.Invoke();
-    }
-  }
-}

+ 3 - 3
MultiplayerClientSpawn/ItemUtil.cs

@@ -1,5 +1,5 @@
-using UnityEngine;
-using GadgetCore.API;
+using GadgetCore.API;
+using UnityEngine;
 
 namespace MultiplayerClientSpawn
 {
@@ -36,7 +36,7 @@ namespace MultiplayerClientSpawn
           mainTexture = texturePartA
         };
       }
-      
+
       Component.Destroy(gameObject.GetComponentInChildren<SpawnBlock>());
       gameObject.AddComponent<MultiplayerSpawnBlock>();
 

+ 2 - 1
MultiplayerClientSpawn/Manifest.ini

@@ -1,3 +1,4 @@
 [Metadata]
 Name=Multiplayer Client Spawn
-Assembly=MultiplayerClientSpawn.dll
+Assembly=MultiplayerClientSpawn.dll
+Dependencies=Scrap Yard

+ 4 - 3
MultiplayerClientSpawn/MultiplayerClientSpawn.cs

@@ -1,13 +1,13 @@
-using UnityEngine;
 using GadgetCore.API;
 using GadgetCore.API.ConfigMenu;
+using ScrapYard.API;
 
 namespace MultiplayerClientSpawn
 {
-  [Gadget("MultiplayerClientSpawn")]
+  [Gadget("MultiplayerClientSpawn", LoadAfter: new string[] { "ScrapYard" }, Dependencies: new string[] { "ScrapYard" })]
   public class MultiplayerClientSpawn : Gadget<MultiplayerClientSpawn>
   {
-    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; }
@@ -23,6 +23,7 @@ namespace MultiplayerClientSpawn
       Core.logger = Logger;
 
       Core.itemSpawnId = ItemUtil.CreatePlacableSpawnItem("spawnpoint.png", "iSpawn.png", "spawnpoint0.png", "spawnpoint1.png", "Multiplayer Spawn");
+      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(Core.itemSpawnId, 10));
     }
   }
 }

+ 5 - 21
MultiplayerClientSpawn/MultiplayerClientSpawn.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>
@@ -167,27 +172,6 @@
     <None Update="Assets\spawnpoint1.png">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>
-    <None Update="Assets\stand0.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-    <None Update="Assets\stand1.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-    <None Update="Assets\stand2.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-    <None Update="Assets\stand3.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-    <None Update="Assets\stand4.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-    <None Update="Assets\stand5.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
-    <None Update="Assets\stand6.png">
-      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
-    </None>
     <None Update="Manifest.ini">
       <CopyToOutputDirectory>Always</CopyToOutputDirectory>
     </None>

+ 2 - 3
MultiplayerClientSpawn/MultiplayerSpawnBlock.cs

@@ -1,5 +1,4 @@
-using System;
-using UnityEngine;
+using UnityEngine;
 
 namespace MultiplayerClientSpawn
 {
@@ -19,7 +18,7 @@ namespace MultiplayerClientSpawn
 
     private void OnConnectedToServer()
     {
-      if (MenuScript.player && Network.isClient)
+      if (Network.isClient)
       {
         MenuScript.player.transform.position = base.transform.position;
       }

+ 0 - 74
MultiplayerClientSpawn/Patches/Patch_KylockeStand_Awake.cs

@@ -1,74 +0,0 @@
-using GadgetCore.API;
-using GadgetCore.Util;
-using HarmonyLib;
-using System.Collections;
-using System.Threading;
-using System.Windows.Threading;
-using UnityEngine;
-
-namespace MultiplayerClientSpawn.Patches
-{
-
-  [HarmonyPatch(typeof(KylockeStand))]
-  [HarmonyPatch("Awake")]
-  [HarmonyGadget("MultiplayerClientSpawn")]
-  public static class Patch_KylockeStand_Awake
-  {
-    [HarmonyPostfix]
-    public static void Prefix(KylockeStand __instance)
-    {
-      __instance.StartCoroutine(StartUpdateLoop(__instance));
-    }
-
-    public static IEnumerator LightColorUpdateLoop(KylockeStand instance)
-    {
-      while (!Network.isServer && !Network.isClient)
-      {
-        yield return new WaitForSeconds(0f);
-      }
-
-      if (Network.isServer)
-      {
-        while (true)
-        {
-          yield return new WaitForSeconds(1f);
-          if (instance.gameObject.activeSelf && Network.isServer)
-          {
-            instance.itemID = getItemIdFromIndex(colorIndex);
-            instance.GetComponent<NetworkView>().RPC("Set", RPCMode.All, new object[]
-            {
-              new int[]{ instance.itemID, instance.cost }
-            });
-          }
-          yield return new WaitForSeconds(9f);
-          colorIndex = (colorIndex + 1) % 2;
-        }
-      }
-    }
-
-    private static IEnumerator StartUpdateLoop(KylockeStand instance)
-    {
-      if (instance.itemID == 2403)
-      {
-        instance.StartCoroutine(LightColorUpdateLoop(instance));
-        CoroutineManager newComponent = instance.gameObject.AddComponent<CoroutineManager>();
-        newComponent.SetAction(new System.Action(() => { newComponent.StartCoroutine(LightColorUpdateLoop(instance)); }));
-      }
-      yield break;
-    }
-
-    private static int colorIndex = 0;
-
-    private static int getItemIdFromIndex(int i)
-    {
-      switch (i)
-      {
-        case 0:
-          return 2403;
-        case 1:
-          return Core.itemSpawnId;
-      }
-      return 2403;
-    }
-  }
-}

+ 0 - 92
MultiplayerClientSpawn/Patches/Patch_KylockeStand_Set.cs

@@ -1,92 +0,0 @@
-using GadgetCore.API;
-using GadgetCore.Util;
-using HarmonyLib;
-using System.Collections;
-using System.Linq;
-using UnityEngine;
-
-namespace MultiplayerClientSpawn.Patches
-{
-
-  [HarmonyPatch(typeof(KylockeStand))]
-  [HarmonyPatch("Set")]
-  [HarmonyGadget("MultiplayerClientSpawn")]
-  public static class Patch_KylockeStand_Set
-  {
-    [HarmonyPostfix]
-    public static void Prefix(KylockeStand __instance, int[] p)
-    {
-      if (animate == null)
-      {
-        animate = true;
-        foreach (var gadget in GadgetCore.API.Gadgets.ListAllEnabledGadgets())
-          if (gadget.Info?.ModName == "More Lights" || gadget.Info?.ModName == "Ship Decorations")
-          {
-            animate = false;
-            break;
-          }
-      }
-
-      if (animate ?? false)
-        __instance.StartCoroutine(DoUpdateLampAnimation(__instance));
-      if (new int[] { Core.itemSpawnId, 2403 }.Contains(p[0]))
-        __instance.StartCoroutine(DoUpdateLoadingAnimation(__instance));
-    }
-
-    private static bool? animate = null;
-
-    private static IEnumerator DoUpdateLampAnimation(KylockeStand instance)
-    {
-      if (!GameScript.inInstance)
-      {
-        instance.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/shipdroid" + UnityEngine.Random.Range(0, 3)), Menuu.soundLevel / 10f);
-      }
-      var scale = instance.icon.transform.localScale;
-      instance.icon.transform.localScale = new Vector3(scale.x * 0.90f, scale.y);
-      yield return new WaitForSeconds(0.05f);
-      instance.icon.transform.localScale = new Vector3(scale.x * 0.76f, scale.y);
-      yield return new WaitForSeconds(0.05f);
-      instance.icon.transform.localScale = new Vector3(scale.x * 0.70f, scale.y);
-      yield return new WaitForSeconds(0.05f);
-      instance.icon.transform.localScale = new Vector3(scale.x * 0.76f, scale.y);
-      yield return new WaitForSeconds(0.05f);
-      instance.icon.transform.localScale = new Vector3(scale.x * 0.90f, scale.y);
-      yield return new WaitForSeconds(0.05f);
-      instance.icon.transform.localScale = new Vector3(scale.y, scale.y);
-    }
-
-    private static Texture2D textureStand0 = GadgetCoreAPI.LoadTexture2D("stand0.png");
-    private static Texture2D textureStand1 = GadgetCoreAPI.LoadTexture2D("stand1.png");
-    private static Texture2D textureStand2 = GadgetCoreAPI.LoadTexture2D("stand2.png");
-    private static Texture2D textureStand3 = GadgetCoreAPI.LoadTexture2D("stand3.png");
-    private static Texture2D textureStand4 = GadgetCoreAPI.LoadTexture2D("stand4.png");
-    private static Texture2D textureStand5 = GadgetCoreAPI.LoadTexture2D("stand5.png");
-    private static Texture2D textureStand6 = GadgetCoreAPI.LoadTexture2D("stand6.png");
-
-    private static IEnumerator DoUpdateLoadingAnimation(KylockeStand instance)
-    {
-      UpdateTexture(instance, textureStand0);
-      yield return new WaitForSeconds(1.43f);
-      UpdateTexture(instance, textureStand1);
-      yield return new WaitForSeconds(1.43f);
-      UpdateTexture(instance, textureStand2);
-      yield return new WaitForSeconds(1.43f);
-      UpdateTexture(instance, textureStand3);
-      yield return new WaitForSeconds(1.43f);
-      UpdateTexture(instance, textureStand4);
-      yield return new WaitForSeconds(1.43f);
-      UpdateTexture(instance, textureStand5);
-      yield return new WaitForSeconds(1.43f);
-      UpdateTexture(instance, textureStand6);
-    }
-
-    private static void UpdateTexture(KylockeStand instance, Texture2D texture)
-    {
-      Renderer renderer = instance.gameObject.transform.GetChild(0).gameObject.GetComponentInChildren<Renderer>();
-      renderer.material = new Material(Shader.Find("Unlit/Transparent"))
-      {
-        mainTexture = texture
-      };
-    }
-  }
-}

+ 0 - 2
MultiplayerClientSpawn/Patches/Patch_SpawnBlock_Awake.cs

@@ -1,7 +1,5 @@
 using GadgetCore.API;
-using GadgetCore.Util;
 using HarmonyLib;
-using System.Collections;
 using UnityEngine;
 
 namespace MultiplayerClientSpawn.Patches

+ 0 - 2
MultiplayerClientSpawn/Patches/Patch_SpawnBlock_OnConnectedToServer.cs

@@ -1,7 +1,5 @@
 using GadgetCore.API;
-using GadgetCore.Util;
 using HarmonyLib;
-using System.Collections;
 using UnityEngine;
 
 namespace MultiplayerClientSpawn.Patches

+ 2 - 2
MultiplayerClientSpawn/Properties/AssemblyInfo.cs

@@ -1,9 +1,9 @@
 using System.Reflection;
 using static MultiplayerClientSpawn.MultiplayerClientSpawn;
 
-[assembly: AssemblyProduct("More Lights Mod")] //Set this to the full name of the mod including spaces.
+[assembly: AssemblyProduct("MultiplayerClientSpawn")] //Set this to the full name of the mod including spaces.
 [assembly: AssemblyTitle("More Lights")] //This is only used when mousing over a dll file in Windows explorer.
-[assembly: AssemblyDescription("A Gadget mod for Roguelands, adding some more lights.")] //This is a short description for your mod's assembly.
+[assembly: AssemblyDescription("A mod that adds a multiplayer spawn point.")] //This is a short description for your mod's assembly.
 [assembly: AssemblyCompany("")] //Set this to your name/nickname and/or website
 [assembly: AssemblyCopyright("© 2021 Zariteis. All rights reserved.")] //Set this to your copyright name.
 [assembly: AssemblyVersion(MOD_VERSION)]