Quellcode durchsuchen

[ScrapYard] [2.0.3.8] bug fixes

Zariteis vor 4 Jahren
Ursprung
Commit
f7e8a8a4ea

+ 3 - 3
ScrapYard/Patches/Patch_Chunk_OnDestroy.cs

@@ -7,14 +7,14 @@ namespace ScrapYard.Patches
   [HarmonyPatch(typeof(Chunk))]
   [HarmonyPatch("OnDestroy")]
   [HarmonyGadget("ScrapYard")]
-  static class Patch_Chunk_OnDestroy
+  public static class Patch_Chunk_OnDestroyy
   {
     [HarmonyPrefix]
-    public static void Prefix(ref GameObject[] ___networkStuff)
+    [HarmonyPriority(1010)]
+    public static void Prefix(Chunk __instance, ref GameObject[] ___networkStuff)
     {
       if (___networkStuff.Length > 40)
       {
-        Core.logger.Log("Destroying large Planet");
         if (Network.isServer)
         {
           for (int i = 0; i < ___networkStuff.Length; i++)

+ 0 - 1
ScrapYard/Patches/Patch_GameScript_Talk.cs

@@ -15,7 +15,6 @@ namespace ScrapYard.Patches
       if (a < 0)
       {
         __instance.StartCoroutine(__instance.ExitTalking());
-        Core.logger.Log("Stop talking");
         return false;
       }
       return true;

+ 4 - 1
ScrapYard/Patches/Patch_KylockeStand_Awake.cs

@@ -19,10 +19,13 @@ namespace ScrapYard.Patches
 
     private static IEnumerator Deactivate(KylockeStand instance)
     {
+      while (!Network.isServer && !Network.isClient)
+      {
+        yield return new WaitForSeconds(0.5f);
+      }
       yield return new WaitForSeconds(2f);
       if (instance.itemID >= 2000 && instance.itemID < 2500 || instance.itemID == ItemRegistry.GetItemIDByRegistryName("Gadget Core:Crafter Block"))
       {
-        Core.logger.Log("Hiding a Default Stand with Item " + instance.itemID);
         instance.gameObject.SetActive(false);
       }
       yield break;

+ 16 - 16
ScrapYard/ScrapYard.cs

@@ -10,7 +10,7 @@ namespace ScrapYard
   [Gadget("ScrapYard")]
   public class ScrapYard : Gadget<ScrapYard>
   {
-    public const string MOD_VERSION = "1.2"; // Set this to the version of your mod.
+    public const string MOD_VERSION = "1.3"; // 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.
 
     protected override void LoadConfig()
@@ -61,8 +61,6 @@ namespace ScrapYard
 
       Texture2D textureScrapTrophy = GadgetCoreAPI.LoadTexture2D("iScrapTrophy.png");
 
-      Logger.Log("Loaded Textures");
-
       PlanetInfo scrapYardPlanet = new PlanetInfo(PlanetType.SPECIAL, "Scrap Yard", new GadgetCore.Util.Tuple<int, int>[] { new GadgetCore.Util.Tuple<int, int>(1, 100) });
       scrapYardPlanet.SetPortalInfo(texturePortalSign, texturePlanetPrevIcon, texturePlanetIcon);
       scrapYardPlanet.SetBackgroundInfo(textureParalex, textureParalex0, textureParalex1, textureParalex2, textureParalex3);
@@ -73,9 +71,12 @@ namespace ScrapYard
 
       scrapYardPlanet.PortalUses = -1;
 
-      Logger.Log("Created Planet");
 
-      new ItemInfo(ItemType.GENERIC, "Scrap Trophy", "A rusty trophy.\nUsed for purchasing\nspecial items.", textureScrapTrophy).Register("Scrap Trophy");
+      ItemInfo item = new ItemInfo(ItemType.GENERIC, "Scrap Trophy", "A rusty trophy.\nUsed for purchasing\nspecial items.", textureScrapTrophy);
+      int itemID = ItemRegistry.Singleton.Register(item, "Scrap Trophy");
+      if (itemID == -1)
+        throw new System.Exception("Could not register item " + "Scrap Trophy");
+
 
       { // Scrap Yard Bulding
         var scrapYardShopBuilding = Object.Instantiate((GameObject)Resources.Load("prop/2501"));
@@ -117,7 +118,11 @@ namespace ScrapYard
         Component.DestroyImmediate(scrapYardMerchant.GetComponent<npcTurnScript>());
         GadgetCoreAPI.AddCustomResource("prop/ScrapYard/scrapYardMerchant", scrapYardMerchant);
 
-        TileInfo tile = new TileInfo(TileType.INTERACTIVE, null as Texture2D, new GameObject("scrapyardmerchant")).Register("scrapyardmerchant");
+        ItemInfo tileItem = new ItemInfo(ItemType.GENERIC, "scrapyardmerchant", "Degug item.", null as Texture2D).Register();
+        TileInfo tile = new TileInfo(TileType.INTERACTIVE, null as Texture2D, new GameObject("scrapyardmerchant"), tileItem);
+        int tileID = TileRegistry.Singleton.Register(tile, "scrapyardmerchant");
+        if (tileID == -1)
+          throw new System.Exception("Could not register Tile " + "scrapyardmerchant");
         tile.OnInteract += OnInteractMerchant;
       }
 
@@ -247,12 +252,14 @@ namespace ScrapYard
           mainTexture = GadgetCoreAPI.LoadTexture2D("scrapYardStandInfo.png")
         };
 
-        TileInfo tile = new TileInfo(TileType.INTERACTIVE, null as Texture2D, new GameObject("scrapyardstand")).Register("scrapyardstand");
+        ItemInfo tileItem = new ItemInfo(ItemType.GENERIC, "scrapyardstand", "Degug item.", null as Texture2D).Register();
+        TileInfo tile = new TileInfo(TileType.INTERACTIVE, null as Texture2D, new GameObject("scrapyardstand"), tileItem);
+        int tileID = TileRegistry.Singleton.Register(tile, "scrapyardstand");
+        if (tileID == -1)
+          throw new System.Exception("Could not register Tile " + "scrapyardstand");
         tile.OnInteract += OnInteractStand;
       }
 
-      Logger.Log("Created Prefabes");
-
       // Setting up default shop platforms
       new ShopPlatform("Default Objects", ShopPlatformSpacingType.Near).Register();
       new ShopPlatform("Default Blocks", ShopPlatformSpacingType.Near).Register();
@@ -279,11 +286,8 @@ namespace ScrapYard
 
       ShopPlatform.DefaultWalls.AddShopPlatformEntry(new ShopPlatformEntry(2200, 50));
 
-      Logger.Log("Added Default Objects to the Planet");
-
       SceneManager.sceneLoaded += OnSceneLoaded;
 
-      Logger.Log("Added Scene Hook");
     }
 
     internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
@@ -293,7 +297,6 @@ namespace ScrapYard
         try
         {
           var storageMenu = GameObject.Find("Ship").transform.Find("SHIPPLACES").transform.Find("mech").localPosition = new Vector3(-130f, -5.23f, 0.6f);
-          Core.logger.Log("Moved the Mech");
         }
         catch (System.Exception e) { Core.logger.LogError(e.Message); }
       }
@@ -304,15 +307,12 @@ namespace ScrapYard
 
     private IEnumerator OnInteractStand()
     {
-      Core.logger.Log("Start Interaction Stand");
       try
       {
         PlayerScript.curInteractObj.SendMessage("Request");
-        Core.logger.Log("Requested Item");
         canInteractField.SetValue(InstanceTracker.PlayerScript, true);
         interactingField.SetValue(InstanceTracker.PlayerScript, false);
         InstanceTracker.PlayerScript.w.SetActive(true);
-        Core.logger.Log("Finished Interaction Stand");
       }
       catch(System.Exception e)
       {

+ 2 - 8
ScrapYard/ScrapYardShopStandScript.cs

@@ -72,6 +72,7 @@ namespace ScrapYard
 
     private int GetItemAmount(GameScript gameScript, int id)
     {
+      if (id == 0) return 0;
       int num = 0;
       Item[] inventory = (Item[])inventoryField.GetValue(gameScript);
       for (int i = 0; i < 45; i++)
@@ -115,28 +116,21 @@ namespace ScrapYard
 
     private void Request()
     {
-      Core.logger.Log("Requesting Item in Stand");
       var gameScript = (GameScript)Camera.main.GetComponent("GameScript");
       int num = GetItemAmount(gameScript, currencyItemID);
 
-
-      Core.logger.Log("Got a Price for the Stand: " + num);
-
       if (num >= price)
       {
         base.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/purchase"), Menuu.soundLevel / 10f);
         RemoveItemAmount(gameScript, currencyItemID, price);
         Item item = new Item(itemID, quantity, 0, 0, 0, new int[3], new int[3]);
-        Core.logger.Log("Spawn item");
         GadgetCoreAPI.SpawnItem(base.transform.position, item);
       }
-      else if (itemID != 0)
+      else
       {
-        ItemRegistry.GetItem(itemID);
         GameObject gameObject = (GameObject)Object.Instantiate(Resources.Load("txtError"), MenuScript.player.transform.position, Quaternion.identity);
         gameObject.SendMessage("InitError", "Insufficient Currency!");
       }
-      Core.logger.Log("End Shop request");
     }
 
     public int itemID = 1;