Browse Source

[PlatformBlock] [2.0.2.1] Change of the Item/Tile Registration

Zariteis 4 years ago
parent
commit
ff6828779f
1 changed files with 14 additions and 5 deletions
  1. 14 5
      PlatformBlock/ItemUtil.cs

+ 14 - 5
PlatformBlock/ItemUtil.cs

@@ -10,7 +10,7 @@ namespace PlatformBlock
 
       Texture2D textureTile = GadgetCoreAPI.LoadTexture2D(tileImgPath);
       Texture2D textureItem = GadgetCoreAPI.LoadTexture2D(itemImgPath);
-
+      
       GameObject gameObject = Object.Instantiate<GameObject>((GameObject)Resources.Load("prop/2501"));
       Renderer renderer = gameObject.GetComponentInChildren<Renderer>();
       renderer.material = new Material(Shader.Find("Transparent/Diffuse"))
@@ -52,12 +52,21 @@ namespace PlatformBlock
       onTopTrigger.isTrigger = true;
 
       onTopTrigger.gameObject.AddComponent<PlatformOnTopScript>();
+      
+
+      ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, "", textureItem);
+      int itemID = ItemRegistry.Singleton.Register(itemInfo, name);
+      Core.logger.Log("ItemID:" + itemID);
+      if (itemID < 0)
+        throw new System.Exception("Could not register ItemInfo");
 
+      TileInfo tileInfo = new TileInfo(TileType.NONSOLID, textureTile, gameObject, itemInfo);
+      int tileID = TileRegistry.Singleton.Register(tileInfo, name);
+      Core.logger.Log("TileID:" + tileID);
+      if (tileID < 0)
+        throw new System.Exception("Could not register TileInfo");
 
-      ItemInfo itemInfo = new ItemInfo(0, name, "", textureItem, -1, default, null, null, null, null);
-      itemInfo.Register(name, -1, false);
-      new TileInfo(TileType.NONSOLID, textureTile, gameObject, itemInfo).Register(name, -1, false);
-      return itemInfo.GetID();
+      return itemID;
     }
   }
 }