ItemUtil.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. using GadgetCore.API;
  3. namespace EnginesDeluxe
  4. {
  5. public static class ItemUtil
  6. {
  7. public static int CreateEngineItem(string tileImgPath, string itemImgPath, string componentName, string name, string description, string id)
  8. {
  9. Texture2D texture2D = GadgetCoreAPI.LoadTexture2D(tileImgPath);
  10. Texture2D texture2D2 = GadgetCoreAPI.LoadTexture2D(itemImgPath);
  11. GameObject gameObject = Object.Instantiate<GameObject>((GameObject)Resources.Load("prop/EnginesDeluxe/component/" + componentName));
  12. ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, description, texture2D2);
  13. itemInfo.Register(id);
  14. new TileInfo(TileType.NONSOLID, texture2D, gameObject, itemInfo).Register(id);
  15. return itemInfo.GetID();
  16. }
  17. public static int CreateOverrideEngineItem(string tileImgPath, string itemImgPath, string componentName, string name, string description, string id)
  18. {
  19. Texture2D texture2D = GadgetCoreAPI.LoadTexture2D(tileImgPath);
  20. Texture2D texture2D2 = GadgetCoreAPI.LoadTexture2D(itemImgPath);
  21. GameObject gameObject = Object.Instantiate<GameObject>((GameObject)Resources.Load("prop/EnginesDeluxe/component/" + componentName));
  22. ItemInfo itemInfo = new ItemInfo(ItemType.GENERIC, name, description, texture2D2);
  23. itemInfo.Register(id, 2400);
  24. new TileInfo(TileType.NONSOLID, texture2D, gameObject, itemInfo).Register(id, 2400);
  25. return itemInfo.GetID();
  26. }
  27. }
  28. }