using GadgetCore.API;
using GadgetCore.API.ConfigMenu;
using ScrapYard.API;
using UnityEngine;

namespace CombatChipChest
{
  [Gadget("CombatChipChest", LoadAfter: new string[] { "ScrapYard" }, Dependencies: new string[] { "ScrapYard" })]
  public class CombatChipChest : Gadget<CombatChipChest>
  {
    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 override IGadgetConfigMenu GetConfigMenu() { return null; }
    protected override void LoadConfig() { Config.Reset(); Config.Save(); }

    public override string GetModDescription()
    {
      return "A mod that adds a combat chip chest block for your ship.";
    }

    protected override void Initialize()
    {
      Logger.Log("Combat Chip Chest v" + Info.Mod.Version);
      Core.logger = Logger;

      var tile = ItemUtil.CreatePlacableItem("cCombatSimulator.png", "iCombatSimulator.png", "Combat Chest");
      Core.itemCombatChipChestId = tile.Item.GetID();

      Core.npcID = tile.GetID();

      var asset = GadgetCoreAPI.LoadAssetBundle("menucombat");

      var menuCombat = UnityEngine.Object.Instantiate((GameObject)asset.LoadAsset("assets/resources/menucombat.prefab"));
      menuCombat.transform.localPosition = new Vector3(0, 0, -3);

      menuCombat.AddComponent<MenuOpenEventScript>();

      Core.menu = new MenuInfo(MenuType.CHIP, menuCombat, tile);
      Core.menu.Register("Combat Chip Chest");

      ShopPlatform.DefaultObjects.AddShopPlatformEntry(new ShopPlatformEntry(Core.itemCombatChipChestId, 1000));

    }
  }
}
